## The Geometric Distribution | Extreme Optimization Numerical Libraries for .NET Professional |

The geometric distribution is a special case of the 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:

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.

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.

Copyright Â© 2004-2021,
Extreme Optimization. All rights reserved.

*Extreme Optimization,* *Complexity made simple*, *M#*, and *M
Sharp* are trademarks of ExoAnalytics Inc.

*Microsoft*, *Visual C#, Visual Basic, Visual Studio*, *Visual
Studio.NET*, and the *Optimized for Visual Studio* logo

are
registered trademarks of Microsoft Corporation.