ContentsChapter 2 · Probability4 of 6

2.4

Bernoulli, binomial and Gaussian

In this chapter
  1. 2.1Conditional probability and Bayes' rule
  2. 2.2Random variables
  3. 2.3Expectation, variance, covariance
  4. 2.4Bernoulli, binomial and Gaussian
  5. 2.5Change of variables
  6. 2.6Entropy and cross-entropy
Before you readWhy would heights, measurement errors and exam marks all have roughly the same bell shape?
Watch: Binomial distributions · 3Blue1Brown · Probabilities of probabilities, part 1

A Bernoulli variable is one yes-or-no trial: X=1X = 1 with probability θ\theta else 0. Its mean is θ\theta and its variance is θ(1−θ)\theta(1 - \theta) Every binary label, such as diseased or healthy, is one.

The binomial K∼Bin⁡(n,θ)K \sim \operatorname{Bin}(n, \theta) counts the successes in n independent Bernoulli trials:

P(K=k)=(nk)θk(1−θ)n−k,E[K]=nθ,Var⁡(K)=nθ(1−θ).P(K = k) = \binom{n}{k} \theta^k (1 - \theta)^{n - k}, \qquad E[K] = n\theta, \qquad \operatorname{Var}(K) = n\theta(1 - \theta).

The mean and variance follow from adding n independent copies of the Bernoulli.

The Gaussian (normal) X∼N(μ,σ2)X \sim \mathcal N(\mu, \sigma^2) has density

p(x)=12πσ2exp⁡(−(x−μ)22σ2).p(x) = \frac{1}{\sqrt{2\pi\sigma^2}} \exp\left(-\frac{(x - \mu)^2}{2\sigma^2}\right).

It peaks at μ\mu and about 68% of its mass lies within σ\sigma of the mean and 95% within 2σ2\sigma The z-score z=(x−μ)/σz = (x - \mu)/\sigma says how many standard deviations x is from the mean. The central limit theorem says a sum of many small independent effects is close to Gaussian, which answers the question above.

In d dimensions, x∼N(μ,Σ)x \sim \mathcal N(\mu, \Sigma) has density

p(x)=1(2π)ddet⁡Σexp⁡(−12(x−μ)TΣ−1(x−μ)),p(x) = \frac{1}{\sqrt{(2\pi)^d \det \Sigma}} \exp\left(-\tfrac12 (x - \mu)^T \Sigma^{-1} (x - \mu)\right),

with Σ\Sigma the covariance matrix. Most models in this course assume one of these: logistic regression treats labels as Bernoulli, and least squares treats errors as Gaussian.

012345678910
mean nθ = 3variance nθ(1 − θ) = 2.10
Bars are P(K = k), the chance of k successes in n independent trials. The purple curve is the Gaussian with the same mean and variance. Raise n and the bars take its shape: a sum of many small independent effects is close to Gaussian.
Recall
Give the mean and variance of a Bernoulli(θ\theta variable.
Recall
What does Bin⁡(n,θ)\operatorname{Bin}(n, \theta) count, and what is its mean?
Recall
Why are Gaussians so common in data?
Exercise
Flip a fair coin 4 times. What is the probability of exactly 2 heads?
Exercise
K∼Bin⁡(10,0.3)K \sim \operatorname{Bin}(10, 0.3) Give E[K]E[K] and Var⁡(K)\operatorname{Var}(K)
Exercise
X∼N(10,4)X \sim \mathcal N(10, 4) where 4 is the variance. How many standard deviations above the mean is x=13x = 13