Package com.freevariable.lancer.util
Class SampleRecorder
- java.lang.Object
-
- com.freevariable.lancer.util.SampleRecorder
-
public final class SampleRecorder extends java.lang.Object
A class to manage aggregate statistics for a stream of double values in constant space. Uses the technique from "Updating mean and variance estimates: an improved method", by D. H. D. West (1979).- Since:
- 0.0.1
-
-
Field Summary
Fields Modifier and Type Field Description private long
count
private double
max
private double
meanEstimate
private double
min
private boolean
sd_dirty
private double
stdDevEstimate
private double
sumX
private double
sumXSquared
private double
varianceEstimate
-
Constructor Summary
Constructors Constructor Description SampleRecorder()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description long
count()
Returns the count of samples recorded so far.double
max()
Returns the largest sample recorded so far.double
meanEstimate()
Returns the estimated mean of samples recorded so far.double
min()
Returns the smallest sample recorded so far.void
record(double sample)
Records the given sample.void
reset()
double
stdDevEstimate()
Returns the estimated standard deviation of samples recorded so far; this is computed by need.private void
updateEstimates(double sample)
double
varianceEstimate()
Returns the estimated variance of samples recorded so far.
-
-
-
Field Detail
-
count
private long count
-
meanEstimate
private double meanEstimate
-
varianceEstimate
private double varianceEstimate
-
stdDevEstimate
private double stdDevEstimate
-
sd_dirty
private boolean sd_dirty
-
max
private double max
-
min
private double min
-
sumX
private double sumX
-
sumXSquared
private double sumXSquared
-
-
Method Detail
-
updateEstimates
private void updateEstimates(double sample)
-
reset
public void reset()
-
record
public void record(double sample)
Records the given sample.
-
count
public long count()
Returns the count of samples recorded so far.
-
meanEstimate
public double meanEstimate()
Returns the estimated mean of samples recorded so far.
-
varianceEstimate
public double varianceEstimate()
Returns the estimated variance of samples recorded so far.
-
stdDevEstimate
public double stdDevEstimate()
Returns the estimated standard deviation of samples recorded so far; this is computed by need.
-
max
public double max()
Returns the largest sample recorded so far.
-
min
public double min()
Returns the smallest sample recorded so far.
-
-