public void addMeasurement(double measurement){
  double keepConstant=1 - mDecayConstant;
  if (mCount > mCutover) {
    mValue=Math.exp(keepConstant * Math.log(mValue) + mDecayConstant * Math.log(measurement));
  }
 else   if (mCount > 0) {
    double retained=keepConstant * mCount / (mCount + 1.0);
    double newcomer=1.0 - retained;
    mValue=Math.exp(retained * Math.log(mValue) + newcomer * Math.log(measurement));
  }
 else {
    mValue=measurement;
  }
  mCount++;
}

public void addMeasurement ( double measurement ) { double keepConstant = 1 - mDecayConstant ; if ( mCount > mCutover ) { mValue = Math . exp ( keepConstant * Math . log ( mValue ) + mDecayConstant * Math . log ( measurement ) ) ; } else if ( mCount > 0 ) { double retained = keepConstant * mCount / ( mCount + 1.0 ) ; double newcomer = 1.0 - retained ; mValue = Math . exp ( retained * Math . log ( mValue ) + newcomer * Math . log ( measurement ) ) ; } else { mValue = measurement ; } mCount ++ ; }
adds a new measurement to the moving average .
