Bernoulli Struct
A Bernoulli distribution, where each sample returns either or .
Namespace
RandN.Distributions
Interfaces
Base Types
  • object
  • ValueType
Bernoulli
ValueType
object
IDistribution<bool>

Syntax

public readonly struct Bernoulli : ValueType, IPortableDistribution<bool>, IDistribution<bool>

Methods

NameReturn ValueSummary
FromInverse(ulong)Bernoulli
Creates a new Bernoulli distribution, with a probability of numerator / 2^64.
static
FromP(double)Bernoulli
Creates a new Bernoulli distribution with a probability of p.
static
FromRatio(uint, uint)Bernoulli
Creates a new Bernoulli distribution, with a probability of numerator / denominator.
static
Sample<TRng>(TRng)bool
Samples a value from rng, blocking until a suitable value is returned.
TrySample<TRng>(TRng, bool)bool
Attempts to sample a value from rng once, returning false if the value returned is not suitable. If is returned, the value of result is unspecified.

Extension Methods

NameValueSummary
Select<bool, TResult>(Func<bool, TResult>)IDistribution<TResult>
Transforms a distribution by mapping its values using the selector provided. This method implements the "map" operator from functional programming principles.
SelectMany<bool, TIntermediate, TResult>(Func<bool, IDistribution<TIntermediate>>, Func<bool, TIntermediate, TResult>)IDistribution<TResult>
Transforms a distribution by mapping values using the selector provided to produce a new distribution, which is then sampled from.
SelectMany<bool, TResult>(Func<bool, IDistribution<TResult>>)IDistribution<TResult>
Transforms a distribution by mapping values using the selector provided to produce a new distribution, which is then sampled from. This method implements the "bind" operator from functional programming principles.