|
Infinity Engine v0.6.20
C++ API Documentation
|
Platform-independent Bernoulli distribution. More...
#include <PRNGDistribution.hpp>
Classes | |
| struct | param_type |
| Parameter set for the distribution. More... | |
Public Types | |
| using | result_type = bool |
| The type of values produced by the distribution. | |
Public Member Functions | |
| BernoulliDistribution () | |
| Default constructor. Creates fair Bernoulli distribution (p=0.5). | |
| BernoulliDistribution (double p) | |
| Constructs a Bernoulli distribution with specified success probability. | |
| BernoulliDistribution (const param_type ¶m) | |
| Constructs from a parameter set. | |
| void | reset () |
| Resets the distribution state. | |
| double | p () const |
| Gets the success probability. | |
| param_type | param () const |
| Gets the current parameter set. | |
| void | param (const param_type ¶m) |
| Sets new parameters for the distribution. | |
| result_type | min () const |
| Gets the minimum value that can be generated (false). | |
| result_type | max () const |
| Gets the maximum value that can be generated (true). | |
| template<typename Generator > | |
| result_type | operator() (Generator &g) |
| Generates the next random value using stored parameters. | |
| template<typename Generator > | |
| result_type | operator() (Generator &g, const param_type ¶m) |
| Generates the next random value using provided parameters. | |
Friends | |
| bool | operator== (const BernoulliDistribution &lhs, const BernoulliDistribution &rhs) |
| bool | operator!= (const BernoulliDistribution &lhs, const BernoulliDistribution &rhs) |
Platform-independent Bernoulli distribution.
Produces boolean values according to a Bernoulli trial with success probability p. This is the fundamental building block for discrete probability - a single trial with two possible outcomes (success/failure, true/false, heads/tails).
The Bernoulli distribution is the simplest discrete distribution and forms the basis for many other distributions including binomial, geometric, and negative binomial. It's used for coin flips, binary decisions, success/failure events, or any single trial with two possible outcomes.
Example usage:
| using Infinity::Engine::BernoulliDistribution::result_type = bool |
The type of values produced by the distribution.
|
inline |
Default constructor. Creates fair Bernoulli distribution (p=0.5).
|
inlineexplicit |
Constructs a Bernoulli distribution with specified success probability.
| p | Probability of success (true) |
|
inlineexplicit |
Constructs from a parameter set.
| param | The distribution parameters |
|
inline |
Gets the maximum value that can be generated (true).
|
inline |
Gets the minimum value that can be generated (false).
|
inline |
Generates the next random value using stored parameters.
| Generator | The random number generator type (e.g., PRNG) |
| g | The random number generator |
|
inline |
Generates the next random value using provided parameters.
Generates a uniform random value and compares it to the success probability. Returns true if the uniform value is less than p.
| Generator | The random number generator type (e.g., PRNG) |
| g | The random number generator |
| param | The distribution parameters to use for this generation |
|
inline |
Gets the success probability.
|
inline |
Gets the current parameter set.
|
inline |
Sets new parameters for the distribution.
|
inline |
Resets the distribution state.
No-op for Bernoulli distribution as it maintains no internal state.
|
friend |
|
friend |