public void add ( double x ) { if ( Double . isNaN ( mean ) ) //fist case { mean = x ; variance = 0 ; } else //general case { //first update stnd deviation variance = ( 1 - smoothing ) * ( variance + smoothing * Math . pow ( x - mean , 2 ) ) ; mean = ( 1 - smoothing ) * mean + smoothing * x ; } }
Adds the given data point to the statistics