Class AccumulatorStats
java.lang.Object
microsim.dev.statistics.AccumulatorStats
Sampler that keeps statistical information about the samples.
This is an efficient way to compute simple statistics, e.g. over time, with a small constant memory usage.
-
Constructor Summary
ConstructorsConstructorDescriptionAccumulatorStats(Supplier<? extends Number> source, Consumer<SideEffect> sampleHook) Build an accumulator that samples from the givenSupplier, registered via thesampleHook. -
Method Summary
-
Constructor Details
-
AccumulatorStats
Build an accumulator that samples from the given
Supplier, registered via thesampleHook.A common usage would be to collect a statistic at the end of every time step, leveraging
SimulationEngine.hookStepEnd(SideEffect).For instance, to monitor the size of a population returned by
popSize():var popSizeStats = new AccumulatorStats(popSize, engine::hookStepEnd);- Parameters:
source- The supplier for each sampled value. It will internally be converted to adouble.sampleHook- The hook specifying when sampling is done.
-
-
Method Details
-
lastValue
public double lastValue()Last sampled value. -
min
public double min()Sample minimum. -
max
public double max()Sample maximum. -
sum
public double sum()Sample sum. -
count
public int count()Sample counts. -
mean
public double mean()Sample average. -
unbiasedVariance
public double unbiasedVariance()Running unbiased variance (i.e. using Bessel's correction).
-