@@ -246,7 +246,7 @@ bool CAdaptiveBucketing::initialize(double a, double b, std::size_t n) {
246
246
void CAdaptiveBucketing::initialValues (core_t ::TTime start,
247
247
core_t ::TTime end,
248
248
const TFloatMeanAccumulatorVec& values) {
249
- if (! this ->initialized ()) {
249
+ if (this ->initialized () == false ) {
250
250
return ;
251
251
}
252
252
@@ -406,7 +406,7 @@ void CAdaptiveBucketing::refine(core_t::TTime time) {
406
406
LOG_TRACE (<< " totalAveragingError = " << totalAveragingError);
407
407
408
408
double n_{static_cast <double >(n)};
409
- double step{(1 - n_ * EPS) * totalAveragingError / n_};
409
+ double step{(1.0 - n_ * EPS) * totalAveragingError / n_};
410
410
TFloatVec endpoints{m_Endpoints};
411
411
LOG_TRACE (<< " step = " << step);
412
412
@@ -505,7 +505,7 @@ bool CAdaptiveBucketing::knots(core_t::TTime time,
505
505
double a{m_Endpoints[i]};
506
506
double b{m_Endpoints[i + 1 ]};
507
507
double c{m_Centres[i]};
508
- double c0{c};
508
+ double c0{c - m_Endpoints[ 0 ] };
509
509
knots.push_back (m_Endpoints[0 ]);
510
510
values.push_back (this ->predict (i, time , c));
511
511
variances.push_back (this ->variance (i));
@@ -549,26 +549,37 @@ bool CAdaptiveBucketing::knots(core_t::TTime time,
549
549
double alpha{m_Endpoints[n] - m_Centres[j]};
550
550
double beta{c0};
551
551
double Z{alpha + beta};
552
+ if (Z == 0.0 ) {
553
+ alpha = beta = 0.5 ;
554
+ } else {
555
+ alpha /= Z;
556
+ beta /= Z;
557
+ }
552
558
double lastPeriodValue{
553
559
this ->predict (j, time , m_Centres[j] - m_Endpoints[n])};
554
560
double lastPeriodVariance{this ->variance (j)};
555
561
knots[0 ] = m_Endpoints[0 ];
556
- values[0 ] = ( alpha * values[0 ] + beta * lastPeriodValue) / Z ;
557
- variances[0 ] = ( alpha * variances[0 ] + beta * lastPeriodVariance) / Z ;
562
+ values[0 ] = alpha * values[0 ] + beta * lastPeriodValue;
563
+ variances[0 ] = alpha * variances[0 ] + beta * lastPeriodVariance;
558
564
break ;
559
565
}
560
566
}
561
- for (std::size_t j = 0u ; j < n; ++j) {
567
+ for (std::size_t j = 0 ; j < n; ++j) {
562
568
if (this ->bucketCount (j) > 0.0 ) {
563
569
double alpha{m_Centres[j]};
564
570
double beta{m_Endpoints[n] - knots.back ()};
565
571
double Z{alpha + beta};
572
+ if (Z == 0.0 ) {
573
+ alpha = beta = 0.5 ;
574
+ } else {
575
+ alpha /= Z;
576
+ beta /= Z;
577
+ }
566
578
double nextPeriodValue{
567
579
this ->predict (j, time , m_Endpoints[n] + m_Centres[j])};
568
580
double nextPeriodVariance{this ->variance (j)};
569
- values.push_back ((alpha * values.back () + beta * nextPeriodValue) / Z);
570
- variances.push_back (
571
- (alpha * variances.back () + beta * nextPeriodVariance) / Z);
581
+ values.push_back (alpha * values.back () + beta * nextPeriodValue);
582
+ variances.push_back (alpha * variances.back () + beta * nextPeriodVariance);
572
583
knots.push_back (m_Endpoints[n]);
573
584
break ;
574
585
}
0 commit comments