spot  2.16
Public Member Functions | Protected Attributes | List of all members
spot::barand< gen > Class Template Reference

Compute pseudo-random integer value between 0 and n included, following a binomial distribution with probability p. More...

#include <spot/misc/random.hh>

Collaboration diagram for spot::barand< gen >:

Public Member Functions

 barand (int n, double p)
 Build a binomial random generator. More...
 
int rand () const
 Return a random value. More...
 

Protected Attributes

const int n_
 Upper bound. More...
 
const double m_
 Mean. More...
 
const double s_
 Standard deviation. More...
 

Detailed Description

template<double(*)() gen>
class spot::barand< gen >

Compute pseudo-random integer value between 0 and n included, following a binomial distribution with probability p.

gen must be a random function computing a pseudo-random double value following a standard normal distribution. Use nrand() or bmrand().

Usually approximating a binomial distribution using a normal distribution and is accurate only if n*p and n*(1-p) are greater than 5.

Constructor & Destructor Documentation

◆ barand()

template<double(*)() gen>
spot::barand< gen >::barand ( int  n,
double  p 
)
inline

Build a binomial random generator.

Member Function Documentation

◆ rand()

template<double(*)() gen>
int spot::barand< gen >::rand ( ) const
inline

Member Data Documentation

◆ m_

template<double(*)() gen>
const double spot::barand< gen >::m_
protected

Mean.

Referenced by spot::barand< gen >::rand().

◆ n_

template<double(*)() gen>
const int spot::barand< gen >::n_
protected

Upper bound.

Referenced by spot::barand< gen >::rand().

◆ s_

template<double(*)() gen>
const double spot::barand< gen >::s_
protected

Standard deviation.

Referenced by spot::barand< gen >::rand().


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

Please direct any question, comment, or bug report to the Spot mailing list at spot@lrde.epita.fr.
Generated on Fri Feb 27 2015 10:00:07 for spot by doxygen 1.9.1