# Bernoulli distribution

Release: |
---|

A Bernoulli distribution is perhaps the most basic of all probability distributions. It simply describes a coin flip. There are two possible outcomes, 0 and 1 (equivalently, False and True). The distribution is described by a single parameter, «p», which describes the probability of the outcome True (1).

`Bernoulli(0.75)`

→## Contents

## Functions

### Bernoulli(p*, over*)

Creates a discrete probability distribution with probability «P» of 1 (True) and probability *(1 - P)* of 0 (False). «P» is a probability value or array of probabilities, between 0 and 1. The result is the equivalent to:

Or even just:

`Uniform(0, 1) < p`

If «P» is greater than 1, the distribution is made up of all 1’s. If «P» is less than 0, the distribution is made up of all 0’s.

To generate an array of Bernoulli values that are independent over index `I`

, use the optional «over» parameter:

`Bernoulli(p, over: I)`

You can extend this to an Array with multiple dimensions, as:

`Bernoulli(p, over: I, J, K)`

### ProbBernoulli(k, p)

The analytic probability function for the Bernoulli distribution, which returns the probability that the outcome is k. This is equal to

- $ p(k) = \left\{ \begin{array}{c l} 1-p & \mbox{if } k=0 \\ p & \mbox{if } k=1 \end{array}\right. $

### CumBernoulli(k, p)

The analytic cumulative probability function for the Bernoulli distribution. This returns the probability that the outcome is less than or equal to k, which is simply equal to

- $ F(k) = \left\{ \begin{array}{c l} 0 & \mbox{if } k<0 \\ 1-p & \mbox{if } 0 \le k < 1 \\ 1 & \mbox{if } k\ge 1 \end{array}\right. $

### CumBernoulliInv(q, p)

The analytic inverse cumulative distribution function for the Bernoulli distribution. Returns the smallest Bernoulli(p) outcome, *k*, such that the probability of a random variate being less than or equal to *k* is at least «q».

Both «q» and «p» should be between 0 and 1.

#### Examples

`CumBernoulliInv(0.5, 0.8) → 1`

There is a 0,2 probability of an outcome of 0, which is not "at least" u = 0.5. The probability that the outcome is less than or equal to 1 is 1.0, and 0.0 is at least u = 0.5, so the result here is the outcome 1.

## History

The analytic functions were first introduced into the Distribution Densities Library in Analytica 5.0. They were later moved into Analytica as built-in functions in Analytica 5.2.

Enable comment auto-refresher