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 has one parameter: 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# |
Copy
|
GeometricDistribution geometric = new GeometricDistribution(0.4);
|
| Visual Basic |
Copy
|
Dim geometric As GeometricDistribution = New GeometricDistribution(0.4)
|
The GeometricDistribution class has one specific property, ProbabilityOfSuccess, which
returns the probabiltiy of success of a trial.
GeometricDistribution has one static (Shared in Visual Basic) method, Sample, which generates a
random variate using a user-supplied uniform random number generator.
| C# |
Copy
|
MersenneTwister random = new MersenneTwister();
double variate = GeometricDistribution.GetRandomVariate(random, 0.4);
|
| Visual Basic |
Copy
|
Dim random As MersenneTwister = New MersenneTwister()
Dim variate As Double = GeometricDistribution.GetRandomVariate(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 class.