Celeritas  0.5.0-56+6b053cd
Public Member Functions | List of all members
celeritas::BernoulliDistribution Class Reference

Select one of two options with a given probability. More...

#include <BernoulliDistribution.hh>

Public Types

Type aliases
using result_type = bool
 

Public Member Functions

CELER_FUNCTION BernoulliDistribution (real_type p_true)
 Construct with the probability of returning true.
 
CELER_FUNCTION BernoulliDistribution (real_type scaled_true, real_type scaled_false)
 Construct with the UNnormalized probability of returning true or false.
 
template<class Generator >
CELER_FUNCTION result_type operator() (Generator &rng)
 
real_type p () const
 Probability of returning true from operator()
 
template<class Generator >
CELER_FUNCTION auto operator() (Generator &rng) -> result_type
 Construct with the probability of returning true.
 

Detailed Description

Select one of two options with a given probability.

The constructor argument is the chance of returning true, with an optional second argument for normalizing with a fraction of false values.

BernoulliDistribution snake_eyes(1, 35);
if (snake_eyes(rng))
{
// ...
}
BernoulliDistribution also_snake_eyes(1.0 / 36.0);
CELER_FUNCTION BernoulliDistribution(real_type p_true)
Construct with the probability of returning true.
Definition: BernoulliDistribution.hh:66

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