ExponentialSampler.cpp
Go to the documentation of this file.00001 /**<!--------------------------------------------------------------------> 00002 @file ExponentialSampler.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 an exponential distribution: 00009 X ~ Exp(lambda) ; lambda > 0 00010 f(x) = lambda * exp(-lambda * x) ; x >= 0 00011 E(X) = 1 / lambda 00012 Var(X) = 1 / (lambda ^ 2) 00013 00014 Exponential distributions describe the times (waiting time) between 00015 events in a Poisson process, i.e., a process in which events occur 00016 continuously and independently at a constant average rate. An example 00017 would be the average time you have to wait at a red light before the 00018 light turns green. 00019 <!-------------------------------------------------------------------->**/ 00020 00021 #include "ExponentialSampler.h" 00022 00023 void ExponentialSampler::init() { 00024 Sampler::init(); 00025 00026 ASSERT(m_lambda > 0); 00027 } 00028 00029 Event ExponentialSampler::sample() { 00030 return Event(m_sampler(), this); 00031 } 00032 00033 real_t ExponentialSampler::getPdf(const Event &event) { 00034 const real_t &x = event.getValue<real_t>(); 00035 00036 return m_lambda * exp(-m_lambda * x); 00037 } 00038
Generated on 28 Feb 2009 for Milton by
1.5.6