Public Types | Public Member Functions
RandomLib::ExponentialDistribution Class Reference

The exponential distribution. More...

#include <RandomLib-2010-01/ExponentialDistribution.hpp>

List of all members.

Public Types

typedef RealType result_type

Public Member Functions

template<class Random >
RealType operator() (Random &r, RealType mu=RealType(1)) const throw ()

Detailed Description

The exponential distribution.

Sample from the distribution exp(-x) for x >= 0. This uses the logarithm method, see Knuth, TAOCP, Vol 2, Sec 3.4.1.D. Example

   #include "RandomLib/ExponentialDistribution.hpp"

   RandomLib::Random r;
   std::cout << "Seed set to " << r.SeedString() << std::endl;
   RandomLib::ExponentialDistribution<double> expdist;
   std::cout << "Select from exponential distribution:";
   for (size_t i = 0; i < 10; ++i)
       std::cout << " " << expdist(r);
   std::cout << std::endl;

Member Typedef Documentation

The type returned by ExponentialDistribution::operator()(Random&)

Definition at line 39 of file ExponentialDistribution.hpp.


Member Function Documentation

template<class Random >
RealType RandomLib::ExponentialDistribution::operator() ( Random r,
RealType  mu = RealType(1) 
) const throw () [inline]

Return a sample of type RealType from the exponential distribution and mean mu. This uses Random::FloatU() which avoids taking log(0) and allows rare large values to be returned. If mu = 1, minimum returned value = 0 with prob 1/2p; maximum returned value = log(2)(p + e) with prob 1/2p + e. Here p is the precision of real type RealType and e is the exponent range.

Definition at line 54 of file ExponentialDistribution.hpp.


The documentation for this class was generated from the following file: