public double addNewSample ( double newSample ) { final double sample = calculateLog ( newSample ) ; return Double . longBitsToDouble ( valueEncodedAsLong . updateAndGet ( value -> { return Double . doubleToRawLongBits ( sample * newSampleWeight + ( 1.0 - newSampleWeight ) * Double . longBitsToDouble ( value ) ) ; } ) ) ; }
Adds a new sample to the moving average and returns the updated value .