DiscreteUniformSampler.cpp

Go to the documentation of this file.
00001 /**<!-------------------------------------------------------------------->
00002    @file   DiscreteUniformSampler.cpp
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 discrete uniform distribution
00009          X ~ U(min, max)
00010          p(x) = 1 / (max - min)
00011    <!-------------------------------------------------------------------->**/
00012 
00013 #include "DiscreteUniformSampler.h"
00014 
00015 Event DiscreteUniformSampler::sample() {
00016    const int x = m_sampler();
00017    
00018    if (m_data)
00019       return Event(m_data[x], this);
00020    
00021    return Event(x, this);
00022 }
00023 
00024 real_t DiscreteUniformSampler::getPdf(const Event &event) {
00025    return 1.0 / (m_max - m_min);
00026 }
00027 

Generated on 28 Feb 2009 for Milton by doxygen 1.5.6