Honeycomb  0.1
Component-Model Framework
Classes | Public Types | Public Member Functions | Static Public Attributes | List of all members
honey::Bootstrap< SampleT, Dim, Real__ > Class Template Reference

Monte Carlo (random-based) method to estimate the interval of confidence in a function's result, when that function operates on samples from a complex or unknown distribution. More...

#include <Bootstrap.h>

Classes

struct  meanFunc
 Functor to estimate the sample mean. More...
 
struct  varianceFunc
 Functor to estimate the sample variance. This is the unbiased estimator (mean over all possible samples is the population variance) More...
 

Public Types

typedef Real__ Real
 
typedef Vec< dim, RealVec
 
typedef vector< const SampleT * > SampleList
 
typedef function< Vec(const SampleList &)> Func
 

Public Member Functions

 Bootstrap (const Func &func, RandomGen &gen, const vector< SampleT > &samples, Real alpha=0.05, szt bootSampleCount=50)
 Constructor, set up constants for all calculation calls. More...
 
 ~Bootstrap ()
 
void calc (Real progressDelta=1)
 Perform bootstrap calculation. The calculation can be split up over multiple calls. More...
 
Real progress () const
 Current progress of calculation, from 0 (start) to 1 (complete). More...
 
const Veclower () const
 Get lower bound of confidence interval (calculation must be complete) More...
 
const Vecupper () const
 Get upper bound of confidence interval (calculation must be complete) More...
 

Static Public Attributes

static const sdt dim = Dim
 

Detailed Description

template<class SampleT, sdt Dim = 1, class Real__ = Real>
class honey::Bootstrap< SampleT, Dim, Real__ >

Monte Carlo (random-based) method to estimate the interval of confidence in a function's result, when that function operates on samples from a complex or unknown distribution.

If a function operates on sample data from a distribution, it will produce confident answers with little variation if it has enough samples to work with. For example, a function to find the mean of the number of heads per 10 coin tosses would operate on a large set coin toss samples, and the more samples, the more the mean approaches a stable value – 5 (the mean of a binomial distribution with N=10, p=0.5) But what if the coin is rigged? The distribution becomes unknown, thus the approaching mean is unknown.

The bootstrap method uses the empirical data available (the toss samples) to estimate the stability of the function result (the mean). This stability is expressed as a 95% confidence interval, which says that the mean of any set of toss samples will lie within the interval 95% of the time. It's important to note that the confidence interval is an estimation – the more samples provided, the more accurate and tighter the interval.

Template Parameters
SampleTBootstrap sample data type.
DimDimension of the functor result.
See also
Bootstrap()

Algorithm from "Better Bootstrap Confidence Intervals", Efron, 1987.

Member Typedef Documentation

template<class SampleT , sdt Dim = 1, class Real__ = Real>
typedef function<Vec (const SampleList&)> honey::Bootstrap< SampleT, Dim, Real__ >::Func
template<class SampleT , sdt Dim = 1, class Real__ = Real>
typedef Real__ honey::Bootstrap< SampleT, Dim, Real__ >::Real
template<class SampleT , sdt Dim = 1, class Real__ = Real>
typedef vector<const SampleT*> honey::Bootstrap< SampleT, Dim, Real__ >::SampleList
template<class SampleT , sdt Dim = 1, class Real__ = Real>
typedef Vec<dim,Real> honey::Bootstrap< SampleT, Dim, Real__ >::Vec

Constructor & Destructor Documentation

template<class SampleT , sdt Dim = 1, class Real__ = Real>
honey::Bootstrap< SampleT, Dim, Real__ >::Bootstrap ( const Func func,
RandomGen gen,
const vector< SampleT > &  samples,
Real  alpha = 0.05,
szt  bootSampleCount = 50 
)
inline

Constructor, set up constants for all calculation calls.

The functor operates on a selection of the original samples, and returns a vector of dimension Dim. For example, a coin toss mean functor would count the number of heads per 10 bool samples, and return the average count (a Real) in the form of a 1D vector.

Parameters
funcFunctor to process samples
genRandom generator
samplesSample data to bootstrap.
alphaThe non-confidence of the interval, usually 5%, which gives a 95% confidence interval.
bootSampleCountThe number of function samples to take for estimating the interval. The higher the better, but above 100 is excessive. The total functor call count is: bootSampleCount + samples.size()
template<class SampleT , sdt Dim = 1, class Real__ = Real>
honey::Bootstrap< SampleT, Dim, Real__ >::~Bootstrap ( )
inline

Member Function Documentation

template<class SampleT , sdt Dim, class Real >
void honey::Bootstrap< SampleT, Dim, Real >::calc ( Real  progressDelta = 1)

Perform bootstrap calculation. The calculation can be split up over multiple calls.

When the calculation is complete (progress == 1), the confidence interval for each dimension of the result vector can be retrieved with lower() and upper().

Parameters
progressDeltaPercentage of progress to complete in this call. Range [0,1]
template<class SampleT , sdt Dim = 1, class Real__ = Real>
const Vec& honey::Bootstrap< SampleT, Dim, Real__ >::lower ( ) const
inline

Get lower bound of confidence interval (calculation must be complete)

template<class SampleT , sdt Dim = 1, class Real__ = Real>
Real honey::Bootstrap< SampleT, Dim, Real__ >::progress ( ) const
inline

Current progress of calculation, from 0 (start) to 1 (complete).

template<class SampleT , sdt Dim = 1, class Real__ = Real>
const Vec& honey::Bootstrap< SampleT, Dim, Real__ >::upper ( ) const
inline

Get upper bound of confidence interval (calculation must be complete)

Member Data Documentation

template<class SampleT , sdt Dim = 1, class Real__ = Real>
const sdt honey::Bootstrap< SampleT, Dim, Real__ >::dim = Dim
static

The documentation for this class was generated from the following file: