RandomLib  1.10
 All Classes Namespaces Files Functions Variables Typedefs Enumerator Friends Macros Pages
Public Member Functions | List of all members
RandomLib::InverseEProb Class Reference

Return true with probability 1/e = exp(−1). More...

#include <RandomLib/InverseEProb.hpp>

Public Member Functions

template<class Random >
bool operator() (Random &r)
 

Detailed Description

Return true with probability 1/e = exp(−1).

InverseEProb p; p(Random& r) returns true with prob 1/e using von Neumann's rejection method. It consumes 4.572 bits per call on average.

This class illustrates how to return an exact result using coin tosses only. A more efficient way of returning an exact result would be to use ExponentialProb p; p(r, 1.0f);

Definition at line 30 of file InverseEProb.hpp.

Member Function Documentation

template<class Random >
bool RandomLib::InverseEProb::operator() ( Random r)
inline

Return true with probability 1/e.

Template Parameters
Randomthe type of the random generator.
Parameters
[in,out]ra random generator.
Returns
true with probability 1/e.

Definition at line 61 of file InverseEProb.hpp.


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