DistGeometric

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

Bases: DistDiscrete

The Geometric distribution is the only discrete memoryless random distribution. It is a discrete analog of the exponential distribution. There are two variants, one that indicates the number of Bernoulli trials to get the first success (1, 2, 3, …), and one that indicates the number of failures before the first success (0, 1, 2, …). In line with Law & Kelton, the version of the number of failures before the first success is modeled here, so X ={0, 1, 2, …}. For more information on this distribution see https://mathworld.wolfram.com/GeometricDistribution.html.

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

Construct a new geometric distribution for a repeated set of Bernoulli trials, indicating the number of failures before the first success with probability p of success on each trial.

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

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

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

  • TypeError – when p is not a float:

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

draw() int[source]

Draw a value from the Binomial distribution, where the return value is the number of failures of independent Bernoulli trials until the first success.

probability(observation: int) float[source]

Returns the probability of the observation for the distribution.

property p: float

Return the parameter value p, the probability for success for each individual Bernoulli trial

property stream: StreamInterface

Return the current random stream for this distribution.