Class MovingAverage
- java.lang.Object
-
- com.google.ar.sceneform.utilities.MovingAverage
-
public class MovingAverage extends java.lang.ObjectCalculates an exponentially weighted moving average for a series of data.
-
-
Field Summary
Fields Modifier and Type Field Description static doubleDEFAULT_WEIGHT
-
Constructor Summary
Constructors Constructor Description MovingAverage(double initialSample)Construct an object to track the exponentially weighted moving average for a series of data.MovingAverage(double initialSample, double weight)Construct an object to track the exponentially weighted moving average for a series of data.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidaddSample(double sample)Add a sample and calculate a new average.doublegetAverage()Returns the current average for all samples.
-
-
-
Field Detail
-
DEFAULT_WEIGHT
public static final double DEFAULT_WEIGHT
- See Also:
- Constant Field Values
-
-
Constructor Detail
-
MovingAverage
public MovingAverage(double initialSample)
Construct an object to track the exponentially weighted moving average for a series of data. The weight is set to a default of 0.9, which is good for data with lots of samples when the average should be resistant to spikes (i.e. frame rate).The weight is a ratio between 0 and 1 that represents how much of the previous average is kept compared to the new sample. With a weight of 0.9, 90% of the previous average is kept and 10% of the new sample is added to the average.
- Parameters:
initialSample- the first sample in the average
-
MovingAverage
public MovingAverage(double initialSample, double weight)Construct an object to track the exponentially weighted moving average for a series of data.The weight is a ratio between 0 and 1 that represents how much of the previous average is kept compared to the new sample. With a weight of 0.9, 90% of the previous average is kept and 10% of the new sample is added to the average.
- Parameters:
initialSample- the first sample in the averageweight- the weight to used when adding samples
-
-