Geometric Distribution

The geometric distribution is a special case of the negative binomial distribution. It models the number of failures before the first success in a series of Bernoulli trials. A Bernoulli trial is an experiment with two possible outcomes, labeled 'success' and 'failure,' where the probability of success has a fixed value for all trials.

The geometric distribution has one parameter, p, that specifies the probability of success.

Examples of the geometric distribution are:

  • The number of successive hits by a baseball player (assuming the probability of a hit is constant) has a geometric distribution with parameter p = 1 - (batting average).

  • The number of attempts made by a player to hit a target has a geometric distribution.

The geometric distribution is implemented by the GeometricDistribution class. It has one constructor which takes one argument: the probability of success of a trial. The probability must be between 0 and 1. The following constructs a geometric distribution with probability of success 0.4:

C#
var geometric = new GeometricDistribution(0.4);

The GeometricDistribution class has one specific property, ProbabilityOfSuccess, which returns the probability of success of a trial.

GeometricDistribution has one static (Shared in Visual Basic) method, Sample, which generates a random sample using a user-supplied uniform random number generator.

C#
var random = new MersenneTwister();
int sample = GeometricDistribution.Sample(random, 0.4);

The above example uses the MersenneTwister class to generate uniform random numbers.

For details of the properties and methods common to all discrete probability distribution classes, see the topic on discrete distributions.