Class CaseResamplingReplacementForObject<X>
- java.lang.Object
-
- dev.nm.stat.random.sampler.resampler.bootstrap.CaseResamplingReplacementForObject<X>
-
- All Implemented Interfaces:
ObjectResampler<X>
,Seedable
public class CaseResamplingReplacementForObject<X> extends Object implements ObjectResampler<X>
This is the classical bootstrap method described in the reference. It draws from the original sample with replacement. This implementation is thread-safe that allows concurrent access tonewResample()
by multiple threads.- See Also:
- "B. Efron and R. Tibshirani. An Introduction to the Bootstrap. 1993. Chapman and Hall, New York, London."
- Wikipedia: http://en.wikipedia.org/wiki/Bootstrapping_(statistics)#Case_resampling
-
-
Field Summary
Fields Modifier and Type Field Description static int
DEFAULT_CACHE_SIZE
The default cache size = the number of available processors × 1000.
-
Constructor Summary
Constructors Constructor Description CaseResamplingReplacementForObject(X[] sample, Class<X> clazz)
Constructs a bootstrap sample generator.CaseResamplingReplacementForObject(X[] sample, Class<X> clazz, ConcurrentCachedRLG rlg)
Constructs a bootstrap sample generator.CaseResamplingReplacementForObject(X[] sample, Class<X> clazz, RandomLongGenerator uniform)
Constructs a bootstrap sample generator.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description X[]
newResample()
Gets a resample from the original sample.void
seed(long... seeds)
Seed the random number/vector/scenario generator to produce repeatable experiments.
-
-
-
Constructor Detail
-
CaseResamplingReplacementForObject
public CaseResamplingReplacementForObject(X[] sample, Class<X> clazz)
Constructs a bootstrap sample generator. This is the classical bootstrap with replacement.- Parameters:
sample
- the original sampleclazz
- the class of the sample objects
-
CaseResamplingReplacementForObject
public CaseResamplingReplacementForObject(X[] sample, Class<X> clazz, RandomLongGenerator uniform)
Constructs a bootstrap sample generator. This is the classical bootstrap with replacement.- Parameters:
sample
- the original sampleclazz
- the class of the sample objectsuniform
- a uniform random long generator
-
CaseResamplingReplacementForObject
public CaseResamplingReplacementForObject(X[] sample, Class<X> clazz, ConcurrentCachedRLG rlg)
Constructs a bootstrap sample generator. This is the classical bootstrap with replacement.- Parameters:
sample
- the original sampleclazz
- the class of the sample objectsrlg
- a concurrent uniform random long generator
-
-
Method Detail
-
seed
public void seed(long... seeds)
Description copied from interface:Seedable
Seed the random number/vector/scenario generator to produce repeatable experiments.
-
newResample
public X[] newResample()
Description copied from interface:ObjectResampler
Gets a resample from the original sample. It is very important this method is thread-safe so resampling can be run in parallel.- Specified by:
newResample
in interfaceObjectResampler<X>
- Returns:
- a resample, e.g., a bootstrap sample
-
-