UniformOnSphereSampler.h

Go to the documentation of this file.
00001 /**<!-------------------------------------------------------------------->
00002    @class  UniformOnSphereSampler
00003    @author Travis Fischer (fisch0920@gmail.com)
00004    @author Matthew Jacobs (jacobs.mh@gmail.com)
00005    @date   Fall 2008
00006    
00007    @brief
00008       Represents a uniform distribution on the surface of an N-dimensional 
00009    unit sphere (with parameter N > 0 and radius = 1)
00010    <!-------------------------------------------------------------------->**/
00011 
00012 #ifndef UNIFORM_ON_SPHERE_SAMPLER_H_
00013 #define UNIFORM_ON_SPHERE_SAMPLER_H_
00014 
00015 #include <stats/Sampler.h>
00016 
00017 class UniformOnSphereSampler : public Sampler {
00018    
00019    public:
00020       ///@name Constructors
00021       //@{-----------------------------------------------------------------
00022       
00023       inline explicit UniformOnSphereSampler(unsigned dimension = 3)
00024          : Sampler(), 
00025            m_sampler(Random::s_generator, 
00026                      Random::UniformOnSphereDist(dimension)), 
00027            m_dimension(dimension)
00028       { }
00029       
00030       inline UniformOnSphereSampler(const UniformOnSphereSampler &copy)
00031          : Sampler(copy), 
00032            m_sampler(copy.m_sampler), 
00033            m_dimension(copy.m_dimension)
00034       { }
00035       
00036       virtual ~UniformOnSphereSampler()
00037       { }
00038       
00039       
00040       //@}-----------------------------------------------------------------
00041       ///@name Initialization
00042       //@{-----------------------------------------------------------------
00043       
00044       /**
00045        * @brief
00046        *    Should perform any initialization of this random variable which 
00047        * may be necessary to speed or prepare sampling
00048        * 
00049        * @note should be called before calling sample or getPdf
00050        * @note default implementation initialiazes this random variable's 
00051        *    sample space
00052        */
00053       virtual void init();
00054       
00055       
00056       //@}-----------------------------------------------------------------
00057       ///@name Main usage interface
00058       //@{-----------------------------------------------------------------
00059       
00060       /**
00061        * @returns a randomly chosen event x, sampled from this random 
00062        *    variable's sample space; returned Event has underlying type of 
00063        *    Point3
00064        * @note consecutive calls to sample are expected to return 
00065        *    independent, identically distributed (IID) samples
00066        */
00067       virtual Event sample();
00068       
00069       /**
00070        * @returns the probability density with which the given event would be 
00071        *    sampled according to the underlying probability density function
00072        * @note the given event is assumed to lie within this random variable's
00073        *    sample space
00074        */
00075       virtual real_t getPdf(const Event &event) PURE_FUNCTION;
00076       
00077       
00078       //@}-----------------------------------------------------------------
00079       ///@name Accessors/Mutators
00080       //@{-----------------------------------------------------------------
00081       
00082       /**
00083        * @returns the dimension of the sphere, whose surface 
00084        *    defines the sample space of this random variable
00085        */
00086       inline real_t getDimension() const {
00087          return m_dimension;
00088       }
00089       
00090       /**
00091        * @returns the radius of the N-dimensional sphere, whose surface 
00092        *    defines the sample space of this random variable
00093        */
00094       inline real_t getRadius() const {
00095          return 1.0;
00096       }
00097       
00098       //@}-----------------------------------------------------------------
00099       
00100    protected:
00101       unsigned _factorial(unsigned n);
00102       
00103    protected:
00104       Random::BoostUniformOnSphereSampler m_sampler;
00105       
00106       unsigned m_dimension;
00107 };
00108 
00109 #endif // UNIFORM_ON_SPHERE_SAMPLER_H_
00110 

Generated on 28 Feb 2009 for Milton by doxygen 1.5.6