// @(#)root/roostats:$Id$
// Authors: Kevin Belasco        17/06/2009
// Authors: Kyle Cranmer         17/06/2009
/*************************************************************************
 * Copyright (C) 1995-2008, Rene Brun and Fons Rademakers.               *
 * All rights reserved.                                                  *
 *                                                                       *
 * For the licensing terms see $ROOTSYS/LICENSE.                         *
 * For the list of contributors see $ROOTSYS/README/CREDITS.             *
 *************************************************************************/

//_________________________________________________
/*
BEGIN_HTML
<p>
ProposalFunction is an interface for all proposal functions that would be used with a Markov Chain Monte Carlo algorithm.  
Given a current point in the parameter space it proposes a new point.  
Proposal functions may or may not be symmetric, in the sense that the probability to propose X1 given we are at X2 
need not be the same as the probability to propose X2 given that we are at X1.  In this case, the IsSymmetric method
should return false, and the Metropolis algorithm will need to take into account the proposal density to maintain detailed balance.
</p>
END_HTML
*/
//

#ifndef ROOSTATS_ProposalFunction
#define ROOSTATS_ProposalFunction

#ifndef ROOT_Rtypes
#include "Rtypes.h"
#endif

#ifndef ROO_ARG_SET
#include "RooArgSet.h"
#endif
#ifndef ROO_MSG_SERVICE
#include "RooMsgService.h"
#endif
#ifndef ROOT_TIterator
#include "TIterator.h"
#endif
#ifndef ROO_REAL_VAR
#include "RooRealVar.h"
#endif


namespace RooStats {

   class ProposalFunction : public TObject {

   public:
      //Default constructor
      ProposalFunction() {}

      virtual ~ProposalFunction() {}

      // Populate xPrime with the new proposed point,
      // possibly based on the current point x
      virtual void Propose(RooArgSet& xPrime, RooArgSet& x) = 0;
      
      // Determine whether or not the proposal density is symmetric for
      // points x1 and x2 - that is, whether the probabilty of reaching x2
      // from x1 is equal to the probability of reaching x1 from x2
      virtual Bool_t IsSymmetric(RooArgSet& x1, RooArgSet& x2) = 0;

      // Return the probability of proposing the point x1 given the starting
      // point x2
      virtual Double_t GetProposalDensity(RooArgSet& x1, RooArgSet& x2) = 0;

      // Check the parameters for which the ProposalFunction will
      // propose values to make sure they are all RooRealVars
      // Return true if all objects are RooRealVars, false otherwise
      virtual bool CheckParameters(RooArgSet& params)
      {
         TIterator* it = params.createIterator();
         TObject* obj;
         while ((obj = it->Next()) != NULL) {
            if (!dynamic_cast<RooRealVar*>(obj)) {
               coutE(Eval) << "Error when checking parameters in"
                           << "ProposalFunction: "
                           << "Object \"" << obj->GetName() << "\" not of type "
                           << "RooRealVar" << std::endl;
               delete it;
               return false;
            }
         }
         delete it;
         // Made it here, so all parameters are RooRealVars
         return true;
      }

   protected:
      ClassDef(ProposalFunction,1) // Interface for the proposal function used with Markov Chain Monte Carlo
   };
}

#endif
 ProposalFunction.h:1
 ProposalFunction.h:2
 ProposalFunction.h:3
 ProposalFunction.h:4
 ProposalFunction.h:5
 ProposalFunction.h:6
 ProposalFunction.h:7
 ProposalFunction.h:8
 ProposalFunction.h:9
 ProposalFunction.h:10
 ProposalFunction.h:11
 ProposalFunction.h:12
 ProposalFunction.h:13
 ProposalFunction.h:14
 ProposalFunction.h:15
 ProposalFunction.h:16
 ProposalFunction.h:17
 ProposalFunction.h:18
 ProposalFunction.h:19
 ProposalFunction.h:20
 ProposalFunction.h:21
 ProposalFunction.h:22
 ProposalFunction.h:23
 ProposalFunction.h:24
 ProposalFunction.h:25
 ProposalFunction.h:26
 ProposalFunction.h:27
 ProposalFunction.h:28
 ProposalFunction.h:29
 ProposalFunction.h:30
 ProposalFunction.h:31
 ProposalFunction.h:32
 ProposalFunction.h:33
 ProposalFunction.h:34
 ProposalFunction.h:35
 ProposalFunction.h:36
 ProposalFunction.h:37
 ProposalFunction.h:38
 ProposalFunction.h:39
 ProposalFunction.h:40
 ProposalFunction.h:41
 ProposalFunction.h:42
 ProposalFunction.h:43
 ProposalFunction.h:44
 ProposalFunction.h:45
 ProposalFunction.h:46
 ProposalFunction.h:47
 ProposalFunction.h:48
 ProposalFunction.h:49
 ProposalFunction.h:50
 ProposalFunction.h:51
 ProposalFunction.h:52
 ProposalFunction.h:53
 ProposalFunction.h:54
 ProposalFunction.h:55
 ProposalFunction.h:56
 ProposalFunction.h:57
 ProposalFunction.h:58
 ProposalFunction.h:59
 ProposalFunction.h:60
 ProposalFunction.h:61
 ProposalFunction.h:62
 ProposalFunction.h:63
 ProposalFunction.h:64
 ProposalFunction.h:65
 ProposalFunction.h:66
 ProposalFunction.h:67
 ProposalFunction.h:68
 ProposalFunction.h:69
 ProposalFunction.h:70
 ProposalFunction.h:71
 ProposalFunction.h:72
 ProposalFunction.h:73
 ProposalFunction.h:74
 ProposalFunction.h:75
 ProposalFunction.h:76
 ProposalFunction.h:77
 ProposalFunction.h:78
 ProposalFunction.h:79
 ProposalFunction.h:80
 ProposalFunction.h:81
 ProposalFunction.h:82
 ProposalFunction.h:83
 ProposalFunction.h:84
 ProposalFunction.h:85
 ProposalFunction.h:86
 ProposalFunction.h:87
 ProposalFunction.h:88
 ProposalFunction.h:89
 ProposalFunction.h:90
 ProposalFunction.h:91
 ProposalFunction.h:92
 ProposalFunction.h:93
 ProposalFunction.h:94
 ProposalFunction.h:95
 ProposalFunction.h:96
 ProposalFunction.h:97