Sampler.h

Go to the documentation of this file.
00001 /**<!-------------------------------------------------------------------->
00002    @class  Sampler
00003    @author Travis Fischer (fisch0920@gmail.com)
00004    @author Matthew Jacobs (jacobs.mh@gmail.com)
00005    @date   Fall 2008
00006    
00007    @brief
00008       Represents an abstract random variable that can be sampled according 
00009    to some discrete/continuous probability distribution
00010    <!-------------------------------------------------------------------->**/
00011 
00012 #ifndef SAMPLER_H_
00013 #define SAMPLER_H_
00014 
00015 #include <stats/Event.h>
00016 
00017 class Sampler {
00018    
00019    public:
00020       ///@name Constructors
00021       //@{-----------------------------------------------------------------
00022       
00023       inline   Sampler()
00024       { }
00025       
00026       virtual ~Sampler() 
00027       { }
00028       
00029       
00030       //@}-----------------------------------------------------------------
00031       ///@name Initialization
00032       //@{-----------------------------------------------------------------
00033       
00034       /**
00035        * @brief
00036        *    Should perform any initialization of this random variable which 
00037        * may be necessary to speed or prepare sampling
00038        * 
00039        * @note should be called before calling sample or getPdf
00040        * @note default implementation is empty
00041        */
00042       virtual void init()
00043       { }
00044       
00045       
00046       //@}-----------------------------------------------------------------
00047       ///@name Main usage interface
00048       //@{-----------------------------------------------------------------
00049       
00050       /**
00051        * @returns a randomly chosen event x, sampled from this random 
00052        *    variable's sample space
00053        * @note consecutive calls to sample are expected to return 
00054        *    independent, identically distributed (IID) samples
00055        */
00056       virtual Event sample() = 0;
00057       
00058       /**
00059        * @brief
00060        *    Utility method to both sample this random variable and return 
00061        * the probability density with which that sample was chosen in 
00062        * the out variable pdf.
00063        * 
00064        * @returns a randomly chosen event x, sampled from this random 
00065        *    variable's sample space
00066        * @note consecutive calls to sample are expected to return 
00067        *    independent, identically distributed (IID) samples
00068        */
00069       virtual Event sample(real_t &pdf);
00070       
00071       /**
00072        * @returns the probability density with which the given event would be 
00073        *    sampled according to the underlying probability density function
00074        * @note the given event is assumed to lie within this random variable's
00075        *    sample space
00076        */
00077       virtual real_t getPdf(const Event &event) PURE_FUNCTION = 0;
00078       
00079       
00080       //@}-----------------------------------------------------------------
00081 };
00082 
00083 #include <stats/Random.h>
00084 
00085 #endif // SAMPLER_H_
00086 

Generated on 28 Feb 2009 for Milton by doxygen 1.5.6