# The Bernoulli Distribution

The Bernoulli distribution is the simplest of the discrete probability
distributions. It has two possible outcomes: 0 ('failure') and 1 ('success').
It has a single parameter, *p*, that specifies the probability of
success.

For example, the distribution of heads and tails in coin tossing
has a Bernoulli distribution with *p = 0.5*. The probability
of a newborn to be a girl has a probability distribution with *p = 0.48*
(approximately).

Being the simplest discrete distribution, the Bernoulli distribution is the basic building block for several other discrete probability distributions:

The The Binomial Distribution models the number of successes in a fixed number of trials.

The The Geometric Distribution models the number of failures before the first success.

The The Negative Binomial Distribution models the number of failures before the

*n*th success.

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

`var bernoulli = new BernoulliDistribution(0.4);`

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

BernoulliDistribution
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 = BernoulliDistribution.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.