jsat.math
Class ExponentialMovingStatistics
- java.lang.Object
-
- jsat.math.ExponentialMovingStatistics
-
- All Implemented Interfaces:
- java.io.Serializable, java.lang.Cloneable
public class ExponentialMovingStatistics extends java.lang.Object implements java.io.Serializable, java.lang.CloneableThis class keeps track of a set of Exponential Moving statistics (the mean and standard deviation). When considering just the mean, this is often referred to as Exponential Moving Average (EMA). Similar toOnLineStatistics, this method will use fixed memory to keep an estimate of the mean and standard deviation of a stream of values. However this class will adjust to the mean and standard deviation of only recent additions, and will "forget" the contribution of earlier values. The rate of forgetting is controlled with thesmoothingparameter.- See Also:
- Serialized Form
-
-
Constructor Summary
Constructors Constructor and Description ExponentialMovingStatistics()Creates a new object for keeping an exponential estimate of the mean and variance.ExponentialMovingStatistics(double smoothing)Creates a new object for keeping an exponential estimate of the mean and varianceExponentialMovingStatistics(double smoothing, double mean, double variance)Creates a new object for keeping an exponential estimate of the mean and variance
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method and Description voidadd(double x)Adds the given data point to the statisticsdoublegetMean()doublegetSmoothing()doublegetStandardDeviation()doublegetVariance()voidsetSmoothing(double smoothing)Sets the smoothing parameter value to use.
-
-
-
Constructor Detail
-
ExponentialMovingStatistics
public ExponentialMovingStatistics()
Creates a new object for keeping an exponential estimate of the mean and variance. Uses a relatively low smoothing factor of 0.1
-
ExponentialMovingStatistics
public ExponentialMovingStatistics(double smoothing)
Creates a new object for keeping an exponential estimate of the mean and variance- Parameters:
smoothing- thesmoothingparameter to use
-
ExponentialMovingStatistics
public ExponentialMovingStatistics(double smoothing, double mean, double variance)Creates a new object for keeping an exponential estimate of the mean and variance- Parameters:
smoothing- thesmoothingparameter to usemean- an initial mean. May beNaNto indicate no initial mean.variance- an initial variance. May beNaNto indicate no initial mean.
-
-
Method Detail
-
setSmoothing
public void setSmoothing(double smoothing)
Sets the smoothing parameter value to use. Must be in the range (0, 1]. Changing this value will impact how quickly the statistics adapt to changes, with larger values increasing rate of change and smaller values decreasing it.- Parameters:
smoothing- the smoothing value to use
-
getSmoothing
public double getSmoothing()
- Returns:
- the smoothing parameter in use
-
add
public void add(double x)
Adds the given data point to the statistics- Parameters:
x- the new value to add to the moving statistics
-
getMean
public double getMean()
- Returns:
- estimate of the moving mean
-
getVariance
public double getVariance()
- Returns:
- the estimate of moving variance
-
getStandardDeviation
public double getStandardDeviation()
- Returns:
- the estimate of moving standard deviation
-
-
DataMelt 3.0 © DataMelt by jWork.ORG