Package jslx.statistics
Class MultiBootstrap
- java.lang.Object
-
- jslx.statistics.MultiBootstrap
-
- All Implemented Interfaces:
RNStreamControlIfc
public class MultiBootstrap extends java.lang.Object implements RNStreamControlIfc
A collection of Bootstrap instances to permit multi-dimensional bootstrapping. Construction depends on a named mapping of double[] arrays that represent the original samples. A static create method also allows creation based on a mapping to implementations of the SampleIfc. The name provided for each dataset (or sampler) should be unique and will be used to identify the associated bootstrap results. We call this name a addFactor.
-
-
Field Summary
Fields Modifier and Type Field Description protected java.util.Map<java.lang.String,Bootstrap>
myBootstraps
protected long
myId
The id of this objectprotected java.lang.String
myName
-
Constructor Summary
Constructors Constructor Description MultiBootstrap(java.lang.String name, java.util.Map<java.lang.String,double[]> dataMap)
MultiBootstrap(java.util.Map<java.lang.String,double[]> dataMap)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description void
advanceToNextSubstream()
Positions the RNG at the beginning of its next substream for all bootstrapsjava.lang.String
asString()
static MultiBootstrap
create(int sampleSize, java.util.Map<java.lang.String,SampleIfc> samplerMap)
static MultiBootstrap
create(java.lang.String name, int sampleSize, java.util.Map<java.lang.String,SampleIfc> samplerMap)
static MultiBootstrap
create(java.lang.String name, java.util.Map<java.lang.String,java.util.Map.Entry<java.lang.Integer,SampleIfc>> samplerMap)
static MultiBootstrap
create(java.util.Map<java.lang.String,java.util.Map.Entry<java.lang.Integer,SampleIfc>> samplerMap)
void
generateSamples(int numBootstrapSamples)
The individual bootstrapped samples are not saved.void
generateSamples(int numBootstrapSamples, boolean saveBootstrapSamples)
The estimator is EstimatorIfc.Average()void
generateSamples(int numBootstrapSamples, EstimatorIfc estimator)
The individual bootstrapped samples are not saved.void
generateSamples(int numBootstrapSamples, EstimatorIfc estimator, boolean saveBootstrapSamples)
This method changes the underlying state of the Bootstrap instance by performing the bootstrap sampling.void
generateSamples(java.util.Map<java.lang.String,java.lang.Integer> numBootstrapSamples, EstimatorIfc estimator, boolean saveBootstrapSamples)
This method changes the underlying state of the Bootstrap instance by performing the bootstrap sampling.boolean
getAntitheticOption()
False means at least one is false.Bootstrap
getBootstrap(java.lang.String name)
java.util.List<Bootstrap>
getBootstrapList()
java.util.Map<java.lang.String,java.util.List<RVariableIfc>>
getBootstrapRandomVariables()
Gets a map with key = name, where name is the associated bootstrap name and the value is List holding a RVariableIfc representation for each bootstrap generate within the bootstrap.java.util.Map<java.lang.String,java.util.List<RVariableIfc>>
getBootstrapRandomVariables(boolean useCRN)
Gets a map with key = name, where name is the associated bootstrap name and the value is List holding a RVariableIfc representation for each bootstrap generate within the bootstrap.java.util.Map<java.lang.String,double[]>
getBootstrapSampleAverages()
Gets a map with key = name, where name is the associated bootstrap name and the value is the an array holding the generate averages for each bootstrap samples within the bootstrapjava.util.Map<java.lang.String,java.util.List<double[]>>
getBootstrapSampleData()
Gets a map with key = name, where name is the associated bootstrap name and the value is List holding the generate data for each bootstrap generate within the bootstrap.java.util.Map<java.lang.String,double[]>
getBootstrapSampleData(int b)
Gets a map with key = name, where name is the associated bootstrap name and the value is the generate data for the bth bootstrap generate.double[]
getBootstrapSampleData(java.lang.String name, int b)
java.util.Map<java.lang.String,double[]>
getBootstrapSampleVariances()
Gets a map with key = name, where name is the associated bootstrap name and the value is the an array holding the generate variances for each bootstrap samples within the bootstrapjava.util.List<java.lang.String>
getFactorNames()
long
getId()
java.lang.String
getName()
int
getNumberFactors()
void
resetStartStream()
The resetStartStream method will position the RNG at the beginning of its stream.void
resetStartSubstream()
Resets the position of the RNG at the start of the current substream for all bootstrapsvoid
setAntitheticOption(boolean flag)
Tells all the streams to change their antithetic optionjava.lang.String
toString()
-
-
-
Field Detail
-
myId
protected final long myId
The id of this object
-
myName
protected final java.lang.String myName
-
myBootstraps
protected java.util.Map<java.lang.String,Bootstrap> myBootstraps
-
-
Constructor Detail
-
MultiBootstrap
public MultiBootstrap(java.util.Map<java.lang.String,double[]> dataMap)
- Parameters:
dataMap
- a map holding the name for each data set
-
MultiBootstrap
public MultiBootstrap(java.lang.String name, java.util.Map<java.lang.String,double[]> dataMap)
- Parameters:
name
- the name of the instancedataMap
- a map holding the name for each data set, names cannot be null and the arrays cannot be null
-
-
Method Detail
-
getId
public final long getId()
- Returns:
- the identity is unique to this execution/construction
-
getName
public final java.lang.String getName()
- Returns:
- the name of the bootstrap
-
getNumberFactors
public final int getNumberFactors()
- Returns:
- the number of factors in the multibootstrap
-
getFactorNames
public final java.util.List<java.lang.String> getFactorNames()
- Returns:
- the names of the factors as a list
-
create
public static final MultiBootstrap create(int sampleSize, java.util.Map<java.lang.String,SampleIfc> samplerMap)
- Parameters:
sampleSize
- the size of the original generatesamplerMap
- something to generate the original generate of the provided size- Returns:
- an instance of MultiBootstrap based on data generated from each generate
-
create
public static final MultiBootstrap create(java.lang.String name, int sampleSize, java.util.Map<java.lang.String,SampleIfc> samplerMap)
- Parameters:
name
- the name of the instancesampleSize
- the generate size, all samplers have the same amount sampledsamplerMap
- something to generate the original generate of the provided size- Returns:
- an instance of MultiBootstrap based on data generated from each generate
-
create
public static final MultiBootstrap create(java.util.Map<java.lang.String,java.util.Map.Entry<java.lang.Integer,SampleIfc>> samplerMap)
- Parameters:
samplerMap
- the String of the map is the named identifier for the bootstrap, the entry of the map is a pair (Integer, SamplerIfc) which represents the number to generate and the sampler- Returns:
- an instance of MultiBootstrap based on data generated from each generate
-
create
public static final MultiBootstrap create(java.lang.String name, java.util.Map<java.lang.String,java.util.Map.Entry<java.lang.Integer,SampleIfc>> samplerMap)
- Parameters:
name
- the name of the instancesamplerMap
- the String of the map is the named identifier for the bootstrap, the entry of the map is a pair (Integer, SamplerIfc) which represents the number to generate and the sampler- Returns:
- an instance of MultiBootstrap based on data generated from each generate
-
generateSamples
public final void generateSamples(int numBootstrapSamples)
The individual bootstrapped samples are not saved. The estimator is EstimatorIfc.Average()- Parameters:
numBootstrapSamples
- the number of bootstrap samples to generate
-
generateSamples
public final void generateSamples(int numBootstrapSamples, boolean saveBootstrapSamples)
The estimator is EstimatorIfc.Average()- Parameters:
numBootstrapSamples
- the number of bootstrap samples to generatesaveBootstrapSamples
- indicates that the statistics and data of each bootstrap generate should be saved
-
generateSamples
public final void generateSamples(int numBootstrapSamples, EstimatorIfc estimator)
The individual bootstrapped samples are not saved.- Parameters:
numBootstrapSamples
- the number of bootstrap samples to generateestimator
- a function of the data
-
generateSamples
public void generateSamples(int numBootstrapSamples, EstimatorIfc estimator, boolean saveBootstrapSamples)
This method changes the underlying state of the Bootstrap instance by performing the bootstrap sampling.- Parameters:
numBootstrapSamples
- the number of bootstrap samples to generate, assumes all are the same.estimator
- a function of the datasaveBootstrapSamples
- indicates that the statistics and data of each bootstrap generate should be saved
-
generateSamples
public void generateSamples(java.util.Map<java.lang.String,java.lang.Integer> numBootstrapSamples, EstimatorIfc estimator, boolean saveBootstrapSamples)
This method changes the underlying state of the Bootstrap instance by performing the bootstrap sampling.- Parameters:
numBootstrapSamples
- the number of bootstrap samples to generate for each of the bootstraps, the keys must match the keys in the original data map. If the names do not match then the bootstraps are not generated.estimator
- a function of the datasaveBootstrapSamples
- indicates that the statistics and data of each bootstrap generate should be saved
-
getBootstrapSampleAverages
public java.util.Map<java.lang.String,double[]> getBootstrapSampleAverages()
Gets a map with key = name, where name is the associated bootstrap name and the value is the an array holding the generate averages for each bootstrap samples within the bootstrap- Returns:
- a map of the generate averages
-
getBootstrapSampleVariances
public java.util.Map<java.lang.String,double[]> getBootstrapSampleVariances()
Gets a map with key = name, where name is the associated bootstrap name and the value is the an array holding the generate variances for each bootstrap samples within the bootstrap- Returns:
- a map of the generate averages
-
getBootstrapSampleData
public java.util.Map<java.lang.String,java.util.List<double[]>> getBootstrapSampleData()
Gets a map with key = name, where name is the associated bootstrap name and the value is List holding the generate data for each bootstrap generate within the bootstrap. The size of the list is the number of bootstrap samples generated. Each element of the list is the data associated with each generate.- Returns:
- a map of the list of bootstrap data
-
getBootstrapRandomVariables
public java.util.Map<java.lang.String,java.util.List<RVariableIfc>> getBootstrapRandomVariables()
Gets a map with key = name, where name is the associated bootstrap name and the value is List holding a RVariableIfc representation for each bootstrap generate within the bootstrap. The size of the list is the number of bootstrap samples generated. Each element of the list is a RVariableIfc representation of the data with the bootstrap generate. The stream for every random variable is the same across the bootstraps (but different across factors) to facilitate common random number generation (CRN).- Returns:
- a map of the list of bootstrap random variable representations
-
getBootstrapRandomVariables
public java.util.Map<java.lang.String,java.util.List<RVariableIfc>> getBootstrapRandomVariables(boolean useCRN)
Gets a map with key = name, where name is the associated bootstrap name and the value is List holding a RVariableIfc representation for each bootstrap generate within the bootstrap. The size of the list is the number of bootstrap samples generated. Each element of the list is a RVariableIfc representation of the data with the bootstrap generate.- Parameters:
useCRN
- , if true the stream for every random variable is the same across the bootstraps to facilitate common random number generation (CRN). If false different streams are used for each created random variable- Returns:
- a map of the list of bootstrap random variable representations
-
getBootstrapSampleData
public double[] getBootstrapSampleData(java.lang.String name, int b)
- Parameters:
name
- the name of the bootstrapb
- the bootstrap generate number, b = 1, 2, ... to getNumBootstrapSamples()- Returns:
- the generate generated for the bth bootstrap, if no samples are saved then the array returned is of zero length
-
getBootstrapSampleData
public java.util.Map<java.lang.String,double[]> getBootstrapSampleData(int b)
Gets a map with key = name, where name is the associated bootstrap name and the value is the generate data for the bth bootstrap generate. The size of the array is the size of the generated bootstrap generate, the array may be of zero length if the samples were not saved- Parameters:
b
- the bootstrap generate number, b = 1, 2, ... to getNumBootstrapSamples()- Returns:
- a map holding the bth bootstrap data for each bootstrap
-
getBootstrap
public final Bootstrap getBootstrap(java.lang.String name)
- Parameters:
name
- the name of the Bootstrap to get- Returns:
- the Bootstrap associated with the name
-
getBootstrapList
public java.util.List<Bootstrap> getBootstrapList()
- Returns:
- a list of all the bootstraps
-
toString
public java.lang.String toString()
- Overrides:
toString
in classjava.lang.Object
-
asString
public java.lang.String asString()
- Returns:
- the bootstrap results as a string
-
resetStartStream
public void resetStartStream()
The resetStartStream method will position the RNG at the beginning of its stream. This is the same location in the stream as assigned when the RNG was created and initialized for all bootstraps- Specified by:
resetStartStream
in interfaceRNStreamControlIfc
-
resetStartSubstream
public void resetStartSubstream()
Resets the position of the RNG at the start of the current substream for all bootstraps- Specified by:
resetStartSubstream
in interfaceRNStreamControlIfc
-
advanceToNextSubstream
public void advanceToNextSubstream()
Positions the RNG at the beginning of its next substream for all bootstraps- Specified by:
advanceToNextSubstream
in interfaceRNStreamControlIfc
-
setAntitheticOption
public void setAntitheticOption(boolean flag)
Tells all the streams to change their antithetic option- Specified by:
setAntitheticOption
in interfaceRNStreamControlIfc
- Parameters:
flag
- true means that it produces antithetic variates.
-
getAntitheticOption
public boolean getAntitheticOption()
False means at least one is false.- Specified by:
getAntitheticOption
in interfaceRNStreamControlIfc
- Returns:
- true means on all bootstraps have antithetic option on
-
-