This class simulates a "Bernoulli trial", which is like a coin toss. More...
#include <shark/Rng/Bernoulli.h>
Public Member Functions | |
Bernoulli (RngType &rng, double prob=0.5) | |
bool | operator() (double p) |
Returns a Bernoulli random number, i.e. a "true" or "false" marking the occurrence and non-occurrence of an event respectively, when the probability for the occurrence is "p". More... | |
double | prob () const |
Returns the probability for the occurrence of an event. More... | |
void | prob (double newP) |
Sets the probability for the occurrence of an event to "newP". More... | |
double | p (bool x) const |
This class simulates a "Bernoulli trial", which is like a coin toss.
This class is a thin wrapper for the boost::bernoulli_distribution class. A bernoulli distribution simulates a generalized coin toss. A probability for the occurrence of the event (coin side) is defined. When using the equal probability of "0.5" for the occurrence and non-occurrence of the event (coin side), then the event (coin) is named "normal", otherwise it is named "abnormal".
Definition at line 65 of file Bernoulli.h.
|
inline |
Creates a new Bernoulli random generator using the global generator from instance and sets the probability for the occurrence of the event to "prob". Creates a new Bernoulli random generator instance by using the pseudo random number generator "rng" for the determination of random values and sets the probability for the occurrence of the event to "prob".
Definition at line 82 of file Bernoulli.h.
|
inline |
Returns a Bernoulli random number, i.e. a "true" or "false" marking the occurrence and non-occurrence of an event respectively, when the probability for the occurrence is "p".
Definition at line 101 of file Bernoulli.h.
|
inline |
Returns the probability \(p\) for the occurrence of an event ("x = true") or \(1 - p\) for the non-occurrence ("x = false").
Definition at line 129 of file Bernoulli.h.
References shark::Bernoulli< RngType >::prob().
|
inline |
Returns the probability for the occurrence of an event.
Definition at line 111 of file Bernoulli.h.
Referenced by shark::Bernoulli< RngType >::p().
|
inline |
Sets the probability for the occurrence of an event to "newP".
newP | the new probability for the occurrence of an event |
Definition at line 121 of file Bernoulli.h.