RandomLib
1.10
|
Return true with probability 1/e = exp(−1). More...
#include <RandomLib/InverseEProb.hpp>
Public Member Functions | |
template<class Random > | |
bool | operator() (Random &r) |
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.
|
inline |
Return true with probability 1/e.
Random | the type of the random generator. |
[in,out] | r | a random generator. |
Definition at line 61 of file InverseEProb.hpp.