DebuggingSampler.h

Go to the documentation of this file.
00001 // @(#)root/roostats:$Id: DebuggingSampler.h 34109 2010-06-24 15:00:16Z moneta $
00002 // Author: Kyle Cranmer, Lorenzo Moneta, Gregory Schott, Wouter Verkerke
00003 /*************************************************************************
00004  * Copyright (C) 1995-2008, Rene Brun and Fons Rademakers.               *
00005  * All rights reserved.                                                  *
00006  *                                                                       *
00007  * For the licensing terms see $ROOTSYS/LICENSE.                         *
00008  * For the list of contributors see $ROOTSYS/README/CREDITS.             *
00009  *************************************************************************/
00010 
00011 #ifndef ROOSTATS_DebuggingSampler
00012 #define ROOSTATS_DebuggingSampler
00013 
00014 //_________________________________________________
00015 /*
00016 BEGIN_HTML
00017 <p>
00018 DebuggingSampler is a simple implementation of the DistributionCreator interface used for debugging.
00019 The sampling distribution is uniformly random between [0,1] and is INDEPENDENT of the data.  So it is not useful
00020 for true statistical tests, but it is useful for debugging.
00021 </p>
00022 END_HTML
00023 */
00024 //
00025 
00026 #ifndef ROOT_Rtypes
00027 #include "Rtypes.h"
00028 #endif
00029 
00030 #include <vector>
00031 
00032 #include "RooStats/TestStatSampler.h"
00033 #include "RooStats/SamplingDistribution.h"
00034 
00035 #include "RooRealVar.h"
00036 #include "TRandom.h"
00037 
00038 namespace RooStats {
00039 
00040  class DebuggingSampler: public TestStatSampler {
00041 
00042    public:
00043      DebuggingSampler() {
00044        fTestStatistic = new RooRealVar("UniformTestStatistic","UniformTestStatistic",0,0,1);
00045        fRand = new TRandom();
00046      }
00047      virtual ~DebuggingSampler() {
00048        delete fRand;
00049        delete fTestStatistic;
00050      }
00051     
00052       // Main interface to get a ConfInterval, pure virtual
00053      virtual SamplingDistribution* GetSamplingDistribution(RooArgSet& paramsOfInterest)  {
00054        paramsOfInterest = paramsOfInterest; // avoid warning
00055        // normally this method would be complex, but here it is simple for debugging
00056        std::vector<Double_t> testStatVec;
00057        for(Int_t i=0; i<1000; ++i){
00058          testStatVec.push_back( fRand->Uniform() );
00059        }
00060        return new SamplingDistribution("UniformSamplingDist", "for debugging", testStatVec );
00061      } 
00062 
00063       // Main interface to evaluate the test statistic on a dataset
00064      virtual Double_t EvaluateTestStatistic(RooAbsData& /*data*/, RooArgSet& /*paramsOfInterest*/)  {
00065        //       data = data; // avoid warning
00066        //       paramsOfInterest = paramsOfInterest; // avoid warning
00067        return fRand->Uniform();
00068      }
00069 
00070       // Get the TestStatistic
00071       virtual TestStatistic* GetTestStatistic()  const {
00072          // TODO change to Roo... notifications
00073          cout << "GetTestStatistic() IS NOT IMPLEMENTED FOR THIS SAMPLER. Returning NULL." << endl;
00074          return NULL; /*fTestStatistic;*/
00075       }
00076     
00077       // Get the Confidence level for the test
00078       virtual Double_t ConfidenceLevel()  const {return 1.-fSize;}  
00079 
00080       // Common Initialization
00081       virtual void Initialize(RooAbsArg& /* testStatistic */, RooArgSet& /* paramsOfInterest */, RooArgSet& /* nuisanceParameters */ ) {
00082       }
00083 
00084       // Set the Pdf, add to the the workspace if not already there
00085       virtual void SetPdf(RooAbsPdf&) {}
00086 
00087       // specify the parameters of interest in the interval
00088       virtual void SetParameters(RooArgSet&) {}
00089       // specify the nuisance parameters (eg. the rest of the parameters)
00090       virtual void SetNuisanceParameters(const RooArgSet&) {}
00091       // specify the values of parameters used when evaluating test statistic
00092       virtual void SetParametersForTestStat(const RooArgSet& ) {}
00093       // specify the conditional observables
00094       virtual void SetGlobalObservables(const RooArgSet& ) {}
00095 
00096 
00097       // set the size of the test (rate of Type I error) ( Eg. 0.05 for a 95% Confidence Interval)
00098       virtual void SetTestSize(Double_t size) {fSize = size;}
00099       // set the confidence level for the interval (eg. 0.95 for a 95% Confidence Interval)
00100       virtual void SetConfidenceLevel(Double_t cl) {fSize = 1.-cl;}
00101 
00102       // Set the TestStatistic (want the argument to be a function of the data & parameter points
00103       virtual void SetTestStatistic(TestStatistic* /*testStatistic*/) {
00104          // TODO change to Roo... notifications
00105          cout << "SetTestStatistic(...) IS NOT IMPLEMENTED FOR THIS SAMPLER" << endl;
00106       }
00107       
00108    private:
00109       Double_t fSize;
00110       RooRealVar* fTestStatistic;
00111       TRandom* fRand;
00112 
00113    protected:
00114       ClassDef(DebuggingSampler,1)   // A simple implementation of the DistributionCreator interface
00115    };
00116 }
00117 
00118 
00119 #endif

Generated on Tue Jul 5 14:26:22 2011 for ROOT_528-00b_version by  doxygen 1.5.1