Discrete distribution

Bernoulli distribution

A single trial that succeeds with probability and fails otherwise: one coin flip, one click or no click, one patient who does or does not respond. It is coded as for success and for failure, so its mean is the success rate itself. Every other count of successes on this site is built out of Bernoulli trials.

Bernoulli probability calculator

P(X ≤ 0) = 0.7

At the parameters set by the sliders. The shaded region on the plot is the probability; the dots on the CDF mark F at its ends. For a discrete distribution, < and ≤ differ.

PMF

00.20.40.601P(X = k)mean

CDF

00.250.50.75101F(x)

mean 0.3 · variance 0.21 · sd 0.4583 · mode 0 · entropy 0.6109 nats

Formulas

Parameters
  • , the probability of success
Support
PMF
CDF
Mean
Variance
Mode
MGF
Entropy

Worked example

A basketball player makes 70% of her free throws. Let if she makes the next one. What are the mean and variance of ?

, so and . The variance is largest, , when : a coin flip is the hardest single trial to predict. answer checked by code

How it relates to others

All the relationships, as a diagram →

In Python

from scipy import stats
import numpy as np

X = stats.bernoulli(p=0.3)
X.pmf(1)  # P(X = 1) = 0.3
X.cdf(1)  # P(X ≤ 1) = 1
X.mean(), X.var()  # 0.3, 0.21
X.ppf(0.95)  # 95th percentile
X.rvs(size=10, random_state=0)

rng = np.random.default_rng(0)
rng.binomial(n=1, p=0.3, size=10)

NumPy has no separate Bernoulli sampler: it is a binomial with n = 1.

Choosing between this and its neighbours? Which distribution for count data?

Binomial →