Class SamplingSummaryStat
- java.lang.Object
-
- jasima.core.statistics.SummaryStat
-
- jasima.core.statistics.SamplingSummaryStat
-
- All Implemented Interfaces:
Serializable,Cloneable
public class SamplingSummaryStat extends SummaryStat
This class provides efficient sampling of up to a certain maximum number of values. A SummaryStat-object provides an efficient means to collect basic summary statistics like mean, min, max, standard deviation. To do so it does not have to store any observations. Obtaining information like median, or percentile requires storing values, however. To limit the amount of data which has to be stored, sampling can be used and the aforementioned statistics estimated based on this sample.
This class can sample and store up to a certain maximum number of values. Each value passed to a call of
value(double)has the same probability of ending up in the final sample accessible bygetData().Which values are selected is determined by a random number generator (see
setRnd(Random)). If no such random number generator is set,Math.random()is used.- Author:
- Torsten Hildebrandt, 2012-07-06
- See Also:
- Serialized Form
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description protected static classSamplingSummaryStat.DatEntryEach DatEntry stores a single decision situation plus a random value.
-
Field Summary
-
Fields inherited from class jasima.core.statistics.SummaryStat
DEF_ERROR_PROB, lastValue, lastWeight
-
-
Constructor Summary
Constructors Constructor Description SamplingSummaryStat()SamplingSummaryStat(int numSamples)SamplingSummaryStat(int numSamples, Random rnd)SamplingSummaryStat(Random rnd)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description SummaryStatclone()Clones this object.double[]getData()intgetNumSamples()RandomgetRnd()voidinit()voidsetNumSamples(int numSamples)voidsetRnd(Random rnd)SamplingSummaryStatvalue(double v)Adds the given value with a weight of 1.SummaryStatvalue(double v, double weight)Adds a value with a given weight.-
Methods inherited from class jasima.core.statistics.SummaryStat
clear, combine, combine, confidenceIntervalLower, confidenceIntervalLower, confidenceIntervalUpper, confidenceIntervalUpper, confIntRangeSingle, lastValue, lastWeight, max, mean, min, numObs, stdDev, sum, summarize, summarize, values, varCoeff, variance, variancePopulation, weightSum
-
-
-
-
Method Detail
-
value
public SummaryStat value(double v, double weight)
Description copied from class:SummaryStatAdds a value with a given weight.- Overrides:
valuein classSummaryStat- Parameters:
v- The value to add.weight- The weight to give to this value. Has to be positive.- Returns:
this, to allow easy chaining of calls.
-
value
public SamplingSummaryStat value(double v)
Description copied from class:SummaryStatAdds the given value with a weight of 1.- Overrides:
valuein classSummaryStat- Parameters:
v- The value to add.- Returns:
this, to allow easy chaining of calls.
-
getData
public double[] getData()
-
init
public void init()
-
setRnd
public void setRnd(Random rnd)
-
getRnd
public Random getRnd()
-
setNumSamples
public void setNumSamples(int numSamples)
-
getNumSamples
public int getNumSamples()
-
clone
public SummaryStat clone()
Description copied from class:SummaryStatClones this object. We can use the standard functionality here, as there are only primitive fields.- Overrides:
clonein classSummaryStat- Returns:
- A clone of this
SummaryStat.
-
-