Differences between revisions 11 and 12
Revision 11 as of 2026-08-12 22:16:57
Size: 2681
Comment: Notes
Revision 12 as of 2026-09-01 02:25:46
Size: 2757
Comment: Notes
Deletions are marked like this. Additions are marked like this.
Line 14: Line 14:

Or more formally:
 * ''Prob(X=1) = p''
 * ''Prob(X=0) = 1 - p''
Line 31: Line 35:
Furthermore note that ''E[X] = p'', that ''Prob(X=1) = p'', and that ''Prob(X=0) = 1 - p'': Make the substitutions for ''E[X] = p'', that ''Prob(X=1) = p'', and that ''Prob(X=0) = (1 - p)'':

Bernoulli Distribution

The Bernoulli distribution is a discrete probability density function, specifically giving outcomes 0 or 1.


Description

The distribution gives outcome 1 with probability p, and 0 with probability q = 1 - p. It is appropriate for modeling any binary event.

Or more formally:

  • Prob(X=1) = p

  • Prob(X=0) = 1 - p

A variable distributed this way is notated like X ~ Bernoulli(p). (Sometimes shortened to 'Bern'.)

The sum of repeated and independent Bernoulli-distributed events are described by the binomial distribution.


Moments

The expected value is given as E[X] = p.

Variance is given as Var[X] = p(1 - p) = pq. Observe that the standard calculation for variance of a discrete quantitative random variable simplifies quickly, since there are only two possible values:

var1.svg

Make the substitutions for E[X] = p, that Prob(X=1) = p, and that Prob(X=0) = (1 - p):

var2.svg

It should be clear that this simplifies to p(1-p) immediately.


Usage

Bernoulli Trials

Consider a Bernoulli random variable with probability p. A single trial to observe this variable is called a Bernoulli trial. The sum of repeated (independent) Bernoulli trials is known to follow a binomial distribution. In other words, if X ~ Bernoulli(p) then nX̅ ~ Binomial(n,p).

Sampling

Selection for an experiment can be conceptualized as a Bernoulli event.

The natural implementation of a sample is:

scalar p = .2 /* Probability of selection */
set seed 123456789
generate double r = runiform()
generate sampled = (r < p)

The sample size np is known to follow a binomial distribution.

Conservative Confidence Interval

The variance of a Bernoulli random variable, i.e. p(1 - p), is maximized by p = 1/2. (The same is true for a binomial random variable; Var[X] = np(1 - p).) Therefore Var[X] ≤ 1/4. This leads to the concept of a conservative confidence interval that simply assumes the 'worst case' and sets variance to 1/4.

Following from the De Moivre-Laplace theorem, with a large enough n, a binomial random variable is approximately normal as nX̅ ~ N(X̅, X̅(1-X̅)/n).

This leads to a simple formula for the Wald interval:

wald.svg


CategoryRicottone

Analysis/BernoulliDistribution (last edited 2026-09-01 02:25:46 by DominicRicottone)