|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectbb.science.Bootstrap
public class Bootstrap
Performs statistical bootstrap calculations.
Concerning the quality of the results: bootstrapping is no magic bullet.
So, if you supply garbage inputs, the outputs are also garbage.
One example is insufficient data: the fundamental constructor
will accept a sample which has but one element in it, but the statistical results that are calculated are almost certainly worthless.
This class is multithread safe: it is immutable (both its immediate state, as well as the deep state of its fields).
Nested Class Summary | |
---|---|
static class |
Bootstrap.Estimate
Holds a complete (point and interval) estimate for some Bootstrap.Estimator . |
static interface |
Bootstrap.Estimator
Specifies the api for classes that calculate an estimate for a statistic from a sample. |
static class |
Bootstrap.EstimatorMean
Calculates a point estimate for the population's arithmetic mean from sample. |
static class |
Bootstrap.EstimatorMedian
Calculates a point estimate for the population's median from sample. |
static class |
Bootstrap.EstimatorSd
Calculates a point estimate for the population's standard deviation from sample. |
static class |
Bootstrap.UnitTest
See the Overview page of the project's javadocs for a general description of this unit test class. |
Field Summary | |
---|---|
private double |
confidenceLevel
|
private static double |
confidenceLevel_default
Default value for confidenceLevel . |
private static Bootstrap.Estimator[] |
estimators_default
Default value for the estimators param of the fundamental constructor. |
private ConcurrentHashMap<Bootstrap.Estimator,Bootstrap.Estimate> |
estimatorToEstimate
|
private int |
numberResamples
|
static int |
numberResamples_default
Default value for numberResamples . |
private double[] |
sample
|
Constructor Summary | |
---|---|
Bootstrap(double[] sample)
Convenience constructor that simply calls . |
|
Bootstrap(double[] sample,
int numberResamples)
Convenience constructor that simply calls . |
|
Bootstrap(double[] sample,
int numberResamples,
double confidenceLevel)
Convenience constructor that simply calls . |
|
Bootstrap(double[] sample,
int numberResamples,
double confidenceLevel,
Bootstrap.Estimator... estimators)
Fundamental constructor. |
Method Summary | |
---|---|
private double |
calcAcceleration(Bootstrap.Estimator estimator)
Calculates the acceleration estimation for a BCa bootstrap. |
private double |
calcBias(double point,
double[] resampleEsts,
JSci.maths.statistics.NormalDistribution normalDistribution)
Calculates the bias estimation for a BCa bootstrap. |
private ConcurrentHashMap<Bootstrap.Estimator,Bootstrap.Estimate> |
calcEstimates_BCa(Bootstrap.Estimator[] estimators)
Performs a bootstrap calculation, determining one Bootstrap.Estimate for each element of estimators. |
private ConcurrentHashMap<Bootstrap.Estimator,Bootstrap.Estimate> |
calcEstimates_percentile(Bootstrap.Estimator[] estimators)
Performs a bootstrap calculation, determining one Bootstrap.Estimate for each element of estimators. |
private ConcurrentHashMap<Bootstrap.Estimator,Bootstrap.Estimate> |
calcEstimates(Bootstrap.Estimator[] estimators)
|
private double[] |
calcJackknifeEsts(Bootstrap.Estimator estimator)
Jackknifes sample , calculating a point estimate for each jackknife resample using estimator. |
private Map<Bootstrap.Estimator,double[]> |
doResampling(Bootstrap.Estimator[] estimators)
Generates numberResamples bootstrap resamples. |
Bootstrap.Estimate |
getEstimate(Bootstrap.Estimator estimator)
Returns the Bootstrap.Estimate which corresponds to estimator. |
Bootstrap.Estimate |
getEstimate(String estimatorName)
Returns the first Bootstrap.Estimate which corresponds to estimator with the same name as estimatorName. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public static final int numberResamples_default
numberResamples
.
Its value of 100,000 was recommended by Tim Hesterberg (private communication)
as providing the best balance between high accuracy and reasonable computation time.
private static final double confidenceLevel_default
confidenceLevel
.
Its value of 0.95 is the usual 95% confidence level used in statistics.
private static final Bootstrap.Estimator[] estimators_default
private final double[] sample
private final int numberResamples
private final double confidenceLevel
private final ConcurrentHashMap<Bootstrap.Estimator,Bootstrap.Estimate> estimatorToEstimate
Constructor Detail |
---|
public Bootstrap(double[] sample) throws IllegalArgumentException
this
(sample, numberResamples_default
)
.
IllegalArgumentException
- if sample == null; sample.length == 0public Bootstrap(double[] sample, int numberResamples) throws IllegalArgumentException
this
(sample, numberResamples, confidenceLevel_default
)
.
IllegalArgumentException
- if sample == null; sample.length == 0public Bootstrap(double[] sample, int numberResamples, double confidenceLevel) throws IllegalArgumentException
this
(sample, numberResamples, confidenceLevel, estimators_default
)
.
IllegalArgumentException
- if sample == null; sample.length == 0; numberResamples < 1;
confidenceLevel <= 0 or confidenceLevel >= 1public Bootstrap(double[] sample, int numberResamples, double confidenceLevel, Bootstrap.Estimator... estimators) throws IllegalArgumentException
IllegalArgumentException
- if sample == null; sample.length < 1; numberResamples < 1;
confidenceLevel <= 0 or confidenceLevel >= 1; estimators == null; estimators.length == 0; the names of estimators fail to all be uniqueMethod Detail |
---|
private ConcurrentHashMap<Bootstrap.Estimator,Bootstrap.Estimate> calcEstimates(Bootstrap.Estimator[] estimators)
private ConcurrentHashMap<Bootstrap.Estimator,Bootstrap.Estimate> calcEstimates_percentile(Bootstrap.Estimator[] estimators)
Bootstrap.Estimate
for each element of estimators.
The simple bootstrap percentile method is used to calculate the confidence intervals.
private ConcurrentHashMap<Bootstrap.Estimator,Bootstrap.Estimate> calcEstimates_BCa(Bootstrap.Estimator[] estimators)
Bootstrap.Estimate
for each element of estimators.
The Bias Corrected accelerated (BCa) bootstrap percentile method is used to calculate the confidence intervals.
See pp. 185ff of "An Introduction to the Bootstrap", B. Efron and R. Tibshirani, Chapman and Hall, 1993
for a description of the calculation technique.
private Map<Bootstrap.Estimator,double[]> doResampling(Bootstrap.Estimator[] estimators)
numberResamples
bootstrap resamples.
For each resample, determines one point estimate for each element of estimators.
The result is a Map from each Estimator to its array of resampled point estimates.
Each array is sorted before return.
private double calcBias(double point, double[] resampleEsts, JSci.maths.statistics.NormalDistribution normalDistribution)
private double calcAcceleration(Bootstrap.Estimator estimator)
private double[] calcJackknifeEsts(Bootstrap.Estimator estimator)
sample
, calculating a point estimate for each jackknife resample using estimator.
public Bootstrap.Estimate getEstimate(Bootstrap.Estimator estimator) throws IllegalArgumentException
Bootstrap.Estimate
which corresponds to estimator.
IllegalArgumentException
- if estimator == null; if there is no result for itpublic Bootstrap.Estimate getEstimate(String estimatorName) throws IllegalArgumentException
Bootstrap.Estimate
which corresponds to estimator with the same name as estimatorName.
IllegalArgumentException
- if estimatorName is blank; if there is no result for it
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |