Package com.freevariable.lancer.util
Class SampleRecorder
- java.lang.Object
-
- com.freevariable.lancer.util.SampleRecorder
-
public final class SampleRecorder extends java.lang.ObjectA 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 longcountprivate doublemaxprivate doublemeanEstimateprivate doubleminprivate booleansd_dirtyprivate doublestdDevEstimateprivate doublesumXprivate doublesumXSquaredprivate doublevarianceEstimate
-
Constructor Summary
Constructors Constructor Description SampleRecorder()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description longcount()Returns the count of samples recorded so far.doublemax()Returns the largest sample recorded so far.doublemeanEstimate()Returns the estimated mean of samples recorded so far.doublemin()Returns the smallest sample recorded so far.voidrecord(double sample)Records the given sample.voidreset()doublestdDevEstimate()Returns the estimated standard deviation of samples recorded so far; this is computed by need.private voidupdateEstimates(double sample)doublevarianceEstimate()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.
-
-