Jacknife.h

Go to the documentation of this file.
00001 #ifndef CJACKNIFE_H_
00002 #define CJACKNIFE_H_
00003 #include <numeric>
00004 #include "StatErrEst.h"
00005 #include "statutils.h"
00006 
00007 namespace gplib
00008   {
00009 
00010     /** \addtogroup statistics Statistical methods */
00011     /* @{ */
00012 
00013     //! Implements the Jacknifing method of error estimation
00014     /* This class implements the Jacknifing mehtod for error estimation,
00015      * at this point the implementation is purely geared towards simple mean
00016      * and variance calculation and not easily extensible, should be changed in
00017      * the future
00018      */
00019     template<class SampleGenerator>
00020     class Jacknife: public StatErrEst<SampleGenerator>
00021       {
00022     private:
00023       //! The implementation of the Jacknife
00024       virtual void CalcErrors_Imp(double &m, double &v);
00025     public:
00026       //! The constructor just passes all its arguments to the base class
00027       Jacknife(const int nrea, SampleGenerator TheGenerator) :
00028         StatErrEst<SampleGenerator>::StatErrEst(nrea, TheGenerator)
00029         {
00030         }
00031       virtual ~Jacknife()
00032         {
00033         }
00034       };
00035     /* @} */
00036 
00037     //! The implementation of the Jacknife, has to be in the header file, as it is a template class
00038     template<class SampleGenerator>
00039     void Jacknife<SampleGenerator>::CalcErrors_Imp(double &m, double &v)
00040       {
00041         m = Mean(this->Samples.begin(), this->Samples.end()); //Calculate the mean
00042         if (this->nrealizations < 2) // check for values, that can cause overflow of variance calculation
00043           {
00044             v = 0;
00045             return;
00046           }
00047         v = Variance(this->Samples.begin(), this->Samples.end(), m); //calculate the variance with the given mean
00048       }
00049   }
00050 #endif /*CJACKNIFE_H_*/

Generated on Tue May 4 16:52:14 2010 for GPLIB++ by  doxygen 1.5.8