Bernoulli distribution
- Story. A Bernoulli trial is an experiment that has two outcomes that can be encoded as success (
) or failure (
). The result
of a Bernoulli trial is Bernoulli distributed.
- Example. Check to see if a given bacterium is competent, given that it has probability
of being competent.
- Parameter. The Bernoulli distribution is parametrized by a single value,
, the probability that the trial is successful.
- Support. The Bernoulli distribution may be nonzero only for zero and one.
- Probability mass function.
![\begin{align}f(y;\theta) = \left\{ \begin{array}{ccc}1-\theta & & y = 0 \\(0.5em]\theta & & y = 1.\end{array}\right.\end{align} \begin{align}f(y;\theta) = \left\{ \begin{array}{ccc}1-\theta & & y = 0 \\(0.5em]\theta & & y = 1.\end{array}\right.\end{align}](https://learn.saylor.org/filter/tex/pix.php/c6bce4900d50d03959422e6bbcb5e99f.svg)
Usage
Package |
Syntax |
NumPy |
np.random.choice([0, 1], p=[1-theta, theta]) |
SciPy |
scipy.stats.bernoulli(theta) |
Stan |
bernoulli(theta) |
Related distributions.
- The Bernoulli distribution is a special case of the Binomial distribution with
.
params = [dict(name='θ', start=0, end=1, value=0.5, step=0.01)]
app = distribution_plot_app(x_min=0,
x_max=1,
scipy_dist=st.bernoulli,
params=params,
x_axis_label='y',
title='Bernoulli')
bokeh.io.show(app, notebook_url=notebook_url)