DistBinomial

class pydsol.core.distributions.DistBinomial(stream: StreamInterface, n: int, p: float)[source]

Bases: DistDiscrete

The Binomial distribution is a discrete distribution function that models the probability of the number of successes in a sequence of n independent experiments, each with success (probability p) or failure (probability q = 1 − p). For more information on this distribution see https://mathworld.wolfram.com/BinomialDistribution.html.

__init__(stream: StreamInterface, n: int, p: float)[source]

Constructs a Binomial distribution. It calculates the probability for a number of successes in n independent Bernoulli trials with probability p of success on each trial.

Parameters:
  • stream (StreamInterface) – the random stream to use for this distribution

  • n (int) – the number of independent trials for the Binomial distribution

  • p (float) – the probability for success for each individual trial

Raises:
  • TypeError – when stream is not implementing StreamInterface:

  • TypeError – when p is not a float:

  • TypeError – when n is not an int:

  • ValueError – when p < 0 or p > 1 or n <= 0:

draw() int[source]

Draw a value from the Binomial distribution, where the return value is the number of successes in n independent Bernoulli trials.

probability(observation: int) float[source]

Returns the probability of the observation for the distribution.

property p: float

Return the parameter value p

property n: int

Return the parameter value n

property stream: StreamInterface

Return the current random stream for this distribution.