blitz  Version 0.9
 All Classes Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
exponential.h
Go to the documentation of this file.
1 /*
2  * This generator uses the straightforward transformation
3  * x = - log(y) * m
4  *
5  * to turn a uniform (0,1) y into an exponentially distributed
6  * variable x. x has density function
7  *
8  * f(x) = (1/m) exp(-(1/m)x) (x > 0)
9  *
10  * and mean m.
11  *
12  * NEEDS_WORK: Adapt the method of Ahrens and Dieter. This will
13  * require extending the precision of the constants.
14  *
15  * Ahrens, J.H. and Dieter, U. Computer Methods for Sampling From the
16  * Exponential and Normal Distributions. Comm. ACM, 15,10 (Oct. 1972), p. 873.
17  */
18 
19 #ifndef BZ_RANDOM_EXPONENTIAL
20 #define BZ_RANDOM_EXPONENTIAL
21 
22 #ifndef BZ_RANDOM_UNIFORM
23  #include <random/uniform.h>
24 #endif
25 
26 BZ_NAMESPACE(ranlib)
27 
28 template<typename T = double, typename IRNG = defaultIRNG,
29  typename stateTag = defaultState>
30 class ExponentialUnit : public UniformOpen<T,IRNG,stateTag>
31 {
32 public:
33  typedef T T_numtype;
34 
35  T random()
36  {
38  }
39 };
40 
41 template<typename T = double, typename IRNG = defaultIRNG,
42  typename stateTag = defaultState>
43 class Exponential : public ExponentialUnit<T,IRNG,stateTag> {
44 
45 public:
46  typedef T T_numtype;
47 
48  Exponential(T mean)
49  {
50  mean_ = mean;
51  }
52 
53  T random()
54  {
56  }
57 
58 private:
59  T mean_;
60 };
61 
63 
64 #endif // BZ_RANDOM_EXPONENTIAL