Bernoulli Distribution

Bernoulli Distribution

Definition

Core Statement

The Bernoulli Distribution is the simplest discrete probability distribution. It models a single trial with exactly two possible outcomes: Success (k=1) with probability p, and Failure (k=0) with probability q=1p.

P(X=k)=pk(1p)1kfor k{0,1}

Purpose

  1. Building Block: It is the fundamental atom of probability.
  2. Binary Classification: Modeling Yes/No outcomes (Logistic Regression).

Key Moments

Statistic Formula Intuition
Mean (E[X]) p If p=0.8, average outcome represents 80% success.
Variance (σ2) p(1p) Max variance at p=0.5 (Most uncertainty). Min variance at p=0 or p=1 (Certainty).

Worked Example: Weighted Coin

Problem

A weighted coin lands Heads (1) 70% of the time (p=0.7).

1. Probability of Heads: 0.7.
2. Variance:

σ2=0.7×(10.7)=0.7×0.3=0.21

Contrast: If fair coin (p=0.5): σ2=0.5×0.5=0.25. (Fair coin is more unpredictable).


Assumptions


Python Implementation

from scipy.stats import bernoulli
import matplotlib.pyplot as plt

p = 0.3
rv = bernoulli(p)

# Moments
mean, var = rv.stats(moments='mv')
print(f"Mean: {mean}, Variance: {var}")

# PMF
print(f"Prob of Success: {rv.pmf(1)}")
print(f"Prob of Failure: {rv.pmf(0)}")