RandomLib  1.10
 All Classes Namespaces Files Functions Variables Typedefs Enumerator Friends Macros Pages
Public Types | Public Member Functions | List of all members
RandomLib::ExponentialDistribution< RealType > Class Template Reference

The exponential distribution. More...

#include <RandomLib/ExponentialDistribution.hpp>

Public Types

typedef RealType result_type
 

Public Member Functions

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

Detailed Description

template<typename RealType = double>
class RandomLib::ExponentialDistribution< RealType >

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

std::cout << "Seed set to " << r.SeedString() << "\n";
std::cout << "Select from exponential distribution:";
for (size_t i = 0; i < 10; ++i)
std::cout << " " << expdist(r);
std::cout << "\n";
Template Parameters
RealTypethe real type of the results (default double).

Definition at line 37 of file ExponentialDistribution.hpp.

Member Typedef Documentation

template<typename RealType = double>
typedef RealType RandomLib::ExponentialDistribution< RealType >::result_type

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

Definition at line 42 of file ExponentialDistribution.hpp.

Member Function Documentation

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

Return a sample of type RealType from the exponential distribution and mean μ. This uses Random::FloatU() which avoids taking log(0) and allows rare large values to be returned. If μ = 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.

Template Parameters
Randomthe type of RandomCanonical generator.
Parameters
[in,out]rthe RandomCanonical generator.
[in]muthe mean value of the exponential distribution (default 1).
Returns
the random sample.

Definition at line 62 of file ExponentialDistribution.hpp.


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