|
Infinity Engine v0.6.20
C++ API Documentation
|
Platform-independent binomial distribution. More...
#include <PRNGDistribution.hpp>
Classes | |
| struct | param_type |
| Parameter set for the distribution. More... | |
Public Types | |
| using | result_type = IntType |
| The type of values produced by the distribution. | |
Public Member Functions | |
| BinomialDistribution () | |
| Default constructor. Creates single trial distribution (t=1, p=0.5). | |
| BinomialDistribution (IntType t, double p=0.5) | |
| Constructs a binomial distribution with specified parameters. | |
| BinomialDistribution (const param_type ¶m) | |
| Constructs from a parameter set. | |
| void | reset () |
| Resets the distribution state. | |
| IntType | t () const |
| Gets the number of trials. | |
| 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 (0). | |
| result_type | max () const |
| Gets the maximum value that can be generated (t). | |
| 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 BinomialDistribution &lhs, const BinomialDistribution &rhs) |
| bool | operator!= (const BinomialDistribution &lhs, const BinomialDistribution &rhs) |
Platform-independent binomial distribution.
Produces integer counts of successes in t independent Bernoulli trials, each with success probability p. For large t*p and t*(1-p), uses normal approximation for efficiency; otherwise uses direct simulation.
The binomial distribution models the number of successes in a fixed number of independent yes/no trials, such as number of heads in coin flips, defective items in a batch, or hits in a series of attempts. It's one of the most fundamental discrete distributions in probability theory.
| IntType | Integer type for the result |
Example usage:
| using Infinity::Engine::BinomialDistribution< IntType >::result_type = IntType |
The type of values produced by the distribution.
|
inline |
Default constructor. Creates single trial distribution (t=1, p=0.5).
|
inlineexplicit |
Constructs a binomial distribution with specified parameters.
| t | Number of trials |
| p | Success probability per trial |
|
inlineexplicit |
Constructs from a parameter set.
| param | The distribution parameters |
|
inline |
Gets the maximum value that can be generated (t).
|
inline |
Gets the minimum value that can be generated (0).
|
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.
Uses two methods depending on parameters:
| 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.
Recreates the normal distribution for approximation if needed.
| param | The new distribution parameters |
|
inline |
Resets the distribution state.
Resets the underlying normal distribution if it's being used for approximation.
|
inline |
Gets the number of trials.
|
friend |
|
friend |