@@ -16,34 +16,34 @@ namespace am {
1616 *
1717 */
1818void OnlineStatistics::addData ( double val ) {
19- if ( cb .size () == 0 ) {
19+ if ( cb_ .size () == 0 ) {
2020 mean_ = val;
2121 var_ = NAN;
2222 m2n_ = 0.0 ;
23- } else if ( 1 + cb .size () > cb .capacity () ) {
24- double tmp = cb .back ();
23+ } else if ( 1 + cb_ .size () > cb_ .capacity () ) {
24+ double tmp = cb_ .back ();
2525 // std::cout << *this << std::endl;
2626 double oldmean = mean_;
27- mean_ = mean_ + (val - tmp)/cb .size ();
27+ mean_ = mean_ + (val - tmp)/cb_ .size ();
2828 double delta = mean_ - oldmean;
2929 double alpha = val - tmp;
3030 /* Fix this part here */
31- m2n_ = m2n_ + (delta*delta*cb .size ()) + alpha*(alpha+2 *tmp-2 *mean_ );
32- var_ = m2n_ / cb .size ();
31+ m2n_ = m2n_ + (delta*delta*cb_ .size ()) + alpha*(alpha+2 *tmp-2 *mean_ );
32+ var_ = m2n_ / cb_ .size ();
3333 auto const ip = std::find ( ary_.begin (), ary_.end (), tmp );
3434 if ( ip != ary_.end () ) {
3535 ary_.erase (ip);
3636 }
3737
3838 } else {
3939 double oldmean_ = mean_;
40- mean_ = (val - mean_)/(cb .size ()+1 ) + mean_;
40+ mean_ = (val - mean_)/(cb_ .size ()+1 ) + mean_;
4141 m2n_ = m2n_ + ( val - oldmean_)*(val - mean_ );
42- var_ = m2n_ / (cb .size ()+1 );
42+ var_ = m2n_ / (cb_ .size ()+1 );
4343 }
4444 ary_.insert (ary_.begin (),val );
4545 insertion_sort (ary_);
46- cb .push_front (val);
46+ cb_ .push_front (val);
4747 // std::cout << *this << std::endl;
4848}
4949
@@ -59,14 +59,14 @@ void OnlineStatistics::insertion_sort(std::vector<double>& ary) {
5959
6060void OnlineStatistics::setSize ( size_t N )
6161{
62- cb .set_capacity (N);
63- cb .erase (cb .begin (),cb .end ());
62+ cb_ .set_capacity (N);
63+ cb_ .erase (cb_ .begin (),cb_ .end ());
6464 ary_.clear ();
6565}
6666
6767void OnlineStatistics::setDelayStats ( am_utils::DelayStats &msg )
6868{
69- msg.count = cb .size ();
69+ msg.count = cb_ .size ();
7070 msg.mean_delay = getMean ();
7171 msg.stddev_delay = sqrt (getVariance ());
7272 msg.min_delay = getMin ();
@@ -77,8 +77,8 @@ void OnlineStatistics::setDelayStats( am_utils::DelayStats &msg )
7777std::ostream& operator <<(std::ostream& os, OnlineStatistics &stats) {
7878 // os << stats.cb;
7979 os << " [ " ;
80- for ( auto it = stats.cb .begin () ; it != stats.cb .end (); ++it ) {
81- os << *it << ( it + 1 == stats.cb .end () ? " " : " , " );
80+ for ( auto it = stats.cb_ .begin () ; it != stats.cb_ .end (); ++it ) {
81+ os << *it << ( it + 1 == stats.cb_ .end () ? " " : " , " );
8282 }
8383 os << " ]" ;
8484 return os;
0 commit comments