ProposalFunction.h

Go to the documentation of this file.
00001 // @(#)root/roostats:$Id: ProposalFunction.h 34109 2010-06-24 15:00:16Z moneta $
00002 // Authors: Kevin Belasco        17/06/2009
00003 // Authors: Kyle Cranmer         17/06/2009
00004 /*************************************************************************
00005  * Copyright (C) 1995-2008, Rene Brun and Fons Rademakers.               *
00006  * All rights reserved.                                                  *
00007  *                                                                       *
00008  * For the licensing terms see $ROOTSYS/LICENSE.                         *
00009  * For the list of contributors see $ROOTSYS/README/CREDITS.             *
00010  *************************************************************************/
00011 
00012 //_________________________________________________
00013 /*
00014 BEGIN_HTML
00015 <p>
00016 ProposalFunction is an interface for all proposal functions that would be used with a Markov Chain Monte Carlo algorithm.  
00017 Given a current point in the parameter space it proposes a new point.  
00018 Proposal functions may or may not be symmetric, in the sense that the probability to propose X1 given we are at X2 
00019 need not be the same as the probability to propose X2 given that we are at X1.  In this case, the IsSymmetric method
00020 should return false, and the Metropolis algorithm will need to take into account the proposal density to maintain detailed balance.
00021 </p>
00022 END_HTML
00023 */
00024 //
00025 
00026 #ifndef ROOSTATS_ProposalFunction
00027 #define ROOSTATS_ProposalFunction
00028 
00029 #ifndef ROOT_Rtypes
00030 #include "Rtypes.h"
00031 #endif
00032 
00033 #ifndef ROO_ARG_SET
00034 #include "RooArgSet.h"
00035 #endif
00036 #ifndef ROO_MSG_SERVICE
00037 #include "RooMsgService.h"
00038 #endif
00039 #ifndef ROOT_TIterator
00040 #include "TIterator.h"
00041 #endif
00042 #ifndef ROO_REAL_VAR
00043 #include "RooRealVar.h"
00044 #endif
00045 
00046 using namespace std;
00047 
00048 namespace RooStats {
00049 
00050    class ProposalFunction : public TObject {
00051 
00052    public:
00053       //Default constructor
00054       ProposalFunction() {}
00055 
00056       virtual ~ProposalFunction() {}
00057 
00058       // Populate xPrime with the new proposed point,
00059       // possibly based on the current point x
00060       virtual void Propose(RooArgSet& xPrime, RooArgSet& x) = 0;
00061       
00062       // Determine whether or not the proposal density is symmetric for
00063       // points x1 and x2 - that is, whether the probabilty of reaching x2
00064       // from x1 is equal to the probability of reaching x1 from x2
00065       virtual Bool_t IsSymmetric(RooArgSet& x1, RooArgSet& x2) = 0;
00066 
00067       // Return the probability of proposing the point x1 given the starting
00068       // point x2
00069       virtual Double_t GetProposalDensity(RooArgSet& x1, RooArgSet& x2) = 0;
00070 
00071       // Check the parameters for which the ProposalFunction will
00072       // propose values to make sure they are all RooRealVars
00073       // Return true if all objects are RooRealVars, false otherwise
00074       virtual bool CheckParameters(RooArgSet& params)
00075       {
00076          TIterator* it = params.createIterator();
00077          TObject* obj;
00078          while ((obj = it->Next()) != NULL) {
00079             if (!dynamic_cast<RooRealVar*>(obj)) {
00080                coutE(Eval) << "Error when checking parameters in"
00081                            << "ProposalFunction: "
00082                            << "Object \"" << obj->GetName() << "\" not of type "
00083                            << "RooRealVar" << endl;
00084                delete it;
00085                return false;
00086             }
00087          }
00088          delete it;
00089          // Made it here, so all parameters are RooRealVars
00090          return true;
00091       }
00092 
00093    protected:
00094       ClassDef(ProposalFunction,1) // Interface for the proposal function used with Markov Chain Monte Carlo
00095    };
00096 }
00097 
00098 #endif

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