DistNegBinomial

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

Bases: DistDiscrete

The Negative Binomial distribution, also known as the Pascal distribution or Polya distribution. It gives the probability of x failures where there are s-1 successes in a total of x+s-1 Bernoulli trials, and trial (x+s) is a success. The chance for success is p for each trial. For more information on this distribution see https://mathworld.wolfram.com/NegativeBinomialDistribution.html.

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

Constructs a Negative Binomial distribution. It gives the probability of x failures where there are s-1 successes in a total of x+s-1 Bernoulli trials, and trial (x+s) is a success

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

  • s (int) – the number of successes in the sequence of (x+n) trials, where trial (x+n) is a success.

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

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

  • TypeError – when p is not a float:

  • TypeError – when s is not an int:

  • ValueError – when p < 0 or p > 1 or s <= 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, the probability of success for each individual trial in the negative binomial distribution.

property s: int

Return the parameter value s, the number of successes in the sequence of (x+n) trials, where trial (x+n) is a success.

property stream: StreamInterface

Return the current random stream for this distribution.