# Bernoulli distribution¶

## Story¶

The result $$y$$ of a single Bernoulli trial is Bernoulli distributed.

## Example¶

Check to see if a given bacterium is competent, given that it has probability $$\theta$$ of being competent.

## Parameter¶

The Bernoulli distribution is parametrized by a single value, $$\theta$$, the probability that the trial is successful.

## Support¶

The Bernoulli distribution may be nonzero only for $$y = 0$$ and $$y = 1$$.

## Probability mass function¶

\begin{split}\begin{align} f(y;\theta) = \left\{ \begin{array}{ccc} 1-\theta & & y = 0 \\[0.5em] \theta & & y = 1. \end{array} \right. \end{align}\end{split}

## Moments¶

Mean: $$\theta$$

Variance: $$\theta(1-\theta)$$

## Usage¶

Package

Syntax

NumPy

rg.choice([0, 1], p=[1-theta, theta])

SciPy

scipy.stats.bernoulli(theta)

Stan

bernoulli(theta)