UniformSampler.h
Go to the documentation of this file.00001 /**<!--------------------------------------------------------------------> 00002 @class UniformSampler 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 (either discrete or continuous), 00009 parameterized by [min,max) 00010 <!-------------------------------------------------------------------->**/ 00011 00012 #ifndef UNIFORM_SAMPLER_H_ 00013 #define UNIFORM_SAMPLER_H_ 00014 00015 #include <stats/Sampler.h> 00016 00017 template <typename T> 00018 class UniformSampler : public Sampler { 00019 00020 public: 00021 ///@name Constructors 00022 //@{----------------------------------------------------------------- 00023 00024 inline explicit UniformSampler(T min = -std::numeric_limits<T>::max(), 00025 T max = std::numeric_limits<T>::max()) 00026 : Sampler(), 00027 m_min(min), m_max(max) 00028 { } 00029 00030 inline UniformSampler(const UniformSampler ©) 00031 : Sampler(copy), 00032 m_min(copy.m_min), m_max(copy.m_max) 00033 { } 00034 00035 virtual ~UniformSampler() 00036 { } 00037 00038 00039 //@}----------------------------------------------------------------- 00040 ///@name Initialization 00041 //@{----------------------------------------------------------------- 00042 00043 /** 00044 * @brief 00045 * Should perform any initialization of this random variable which 00046 * may be necessary to speed or prepare sampling 00047 * 00048 * @note should be called before calling sample or getPdf 00049 * @note default implementation initialiazes this random variable's 00050 * sample space 00051 */ 00052 00053 virtual void init() { 00054 Sampler::init(); 00055 00056 ASSERT(m_min <= m_max); 00057 } 00058 00059 00060 //@}----------------------------------------------------------------- 00061 ///@name Accessors/Mutators 00062 //@{----------------------------------------------------------------- 00063 00064 /** 00065 * @returns the mean 'mu' of this normal random variable 00066 */ 00067 inline T getMin() const { 00068 return m_min; 00069 } 00070 00071 /** 00072 * @returns the variance 'sigma squared' of this normal random variable 00073 */ 00074 inline T getMax() const { 00075 return m_max; 00076 } 00077 00078 //@}----------------------------------------------------------------- 00079 00080 protected: 00081 T m_min; 00082 T m_max; 00083 }; 00084 00085 #endif // UNIFORM_SAMPLER_H_ 00086
Generated on 28 Feb 2009 for Milton by
1.5.6