Go to the documentation of this file.00001
00002
00003 #include "vifa_incr_var.h"
00004
00005 void vifa_incr_var::
00006 add_sample(double data_point,
00007 double prev_factor,
00008 double curr_factor)
00009 {
00010
00011 double old_value = data_mean_;
00012 data_mean_ = (prev_factor * data_mean_) + (curr_factor * data_point);
00013
00014
00015 double old_delta = data_mean_ - old_value;
00016 double data_delta = data_mean_ - data_point;
00017 data_var_ = (prev_factor * (data_var_ + old_delta * old_delta)) +
00018 (curr_factor * data_delta * data_delta);
00019
00020
00021 min_max_.update(data_point);
00022
00023
00024 n_++;
00025 }
00026
00027 void vifa_incr_var::
00028 add_sample(double data_point)
00029 {
00030 int current_n = this->get_n();
00031 double prev_factor = ((double)current_n) / (current_n + 1);
00032 double curr_factor = 1.0 / (current_n + 1);
00033 add_sample(data_point, prev_factor, curr_factor);
00034 }