# BernoulliDistribution

represents a Bernoulli distribution with probability parameter p.

# Background & Context

• represents a discrete statistical distribution defined on the real numbers, where the parameter p is represents a probability parameter satisfying . The Bernoulli distribution is sometimes referred to as the coin toss distribution or as the distribution of a Bernoulli trial. It has a discrete probability density function (PDF) that returns the value p at , gives at , and evaluates to 0 for all other real numbers.
• The Bernoulli distribution is named for Swiss mathematician Jacob Bernoulli and is designed to model the simple action of flipping a (fair or unfair) coin. Traditionally, p is thought of as the probability with which the experiment "succeeds" (so that 1 represents a successful experiment), whereas is the probability of "failure" (so that 0 represents a failed experiment). In the coin flip analogy, 1 typically represents heads, while tails is represented by 0. The value corresponds to flipping a fair coin. Despite being defined very simply, the Bernoulli distribution serves as the basis for a number of other, often more complicated mathematical concepts including the Bernoulli sequence in probability, the Bernoulli measure in measure theory, and the Bernoulli scheme in dynamical systems. Within the study of stochastic processes, the Bernoulli distribution is also the motivation behind the so-called Bernoulli process (BernoulliProcess), a discrete-time stochastic process consisting of a (finite or infinite) sequence of random variables, each of which is independent and identically Bernoulli distributed. Moreover, many real-world scenarios showing a well-defined dichotomy of independent outcome possibilities can be modeled as Bernoulli processes. Examples include the probability of rolling a particular value with a single (fair) die and the numbers of defective products, given a defect rate that is independent of the production scale.
• RandomVariate can be used to give one or more machine- or arbitrary-precision pseudorandom variates from a Bernoulli distribution. Distributed[x,BernoulliDistribution[p]], written more concisely as xBernoulliDistribution[p], can be used to assert that a random variable x is distributed according to a Bernoulli distribution. Such an assertion can then be used in functions such as Probability, NProbability, Expectation, and NExpectation.
• The probability density and cumulative distribution functions may be given using PDF[BernoulliDistribution[p],x] and CDF[BernoulliDistribution[p],x]. The mean, median, variance, raw moments, and central moments may be computed using Mean, Median, Variance, Moment, and CentralMoment, respectively. These quantities can be visualized using DiscretePlot.
• DistributionFitTest can be used to test if a given dataset is consistent with a Bernoulli distribution, EstimatedDistribution to estimate a Bernoulli parametric distribution from given data, and FindDistributionParameters to fit data to a Bernoulli distribution. ProbabilityPlot can be used to generate a plot of the CDF of given data against the CDF of a symbolic Bernoulli distribution and QuantilePlot to generate a plot of the quantiles of given data against the quantiles of a symbolic Bernoulli distribution.
• TransformedDistribution can be used to represent a transformed Bernoulli distribution and TruncatedDistribution to represent the distribution of values truncated between upper and lower values. CopulaDistribution can be used to build higher-dimensional distributions that contain a Bernoulli distribution and ProductDistribution can be used to compute a joint distribution with independent component distributions involving Bernoulli distributions.
• BernoulliDistribution is related to a number of other probability distributions. For example, is equivalent to a single instance of BinomialDistribution[1,p], i.e. PDF[BernoulliDistribution[p],k] is identical to Piecewise[Table[{PDF[BinomialDistribution[1,p],l],kl},{l,0,1}]]. Similarly, the sum of n independent Bernoulli variables with common success rate p is modeled by BinomialDistribution[n,p]. In addition, a number of naturally occurring quantities emerging from collections of independent Bernoulli-distributed random variables may be modeled according to other well-known distributions. For example, the number of successes in the first n data points distributed according to has distribution BinomialDistribution[n,p] while the number of trials to get one (respectively r) successes has distribution (respectively).

# Examples

open allclose all

## Basic Examples(4)

Probability mass function:

 In[1]:=
 Out[1]=
 In[2]:=
 Out[2]=

Cumulative distribution function:

 In[1]:=
 Out[1]=
 In[2]:=
 Out[2]=

Mean and variance:

 In[1]:=
 Out[1]=
 In[2]:=
 Out[2]=

Median:

 In[1]:=
 Out[1]=