Bernoulli Distribution

Maths: Statistics for machine learning

2 min read

Published Oct 22 2025, updated Oct 23 2025


40
0
0
0

Machine LearningMathsNumPyPandasPythonStatistics

The Bernoulli distribution models a random experiment that has only two possible outcomes:

  • Success (1) — occurs with probability p
  • Failure (0) — occurs with probability 1 − p

It’s the foundation of binary probability modelling — used whenever outcomes are yes/no, true/false, 1/0, or success/failure.



Probability Mass Function (PMF)

Bernoulli PMF Formula

Where:

  • X = random variable (0 or 1)
  • p = probability of success e.g., P(X = 1)

The sum of probabilities equals 1:
P(X = 0) + P(X = 1) = 1


Examples:

  • Coin toss - Heads or Tails
  • Email classification - Spam or not spam
  • Loan approval - Approved or denied
  • Customer purchase - Purchases or doesn't purchase

Bernoulli Distribution

A simple bar chart with:

  • One bar for 0 (failure) around height ≈ 0.3
  • One bar for 1 (success) around height ≈ 0.7
  • Labeled probabilities that roughly match your chosen p

The two bars represent the probability mass function (PMF) for {0, 1}.





In Machine Learning

  • Binary classification - Bernoulli models binary outcomes (e.g., spam / not spam)
  • Logistic regression - Models the probability of success (1) using a Bernoulli likelihood
  • Naive Bayes (BernoulliNB) - Features are binary and modeled with Bernoulli probabilities
  • Neural networks - Output activations (sigmoid) approximate Bernoulli probabilities

Products from our shop

Docker Cheat Sheet - Print at Home Designs

Docker Cheat Sheet - Print at Home Designs

Docker Cheat Sheet Mouse Mat

Docker Cheat Sheet Mouse Mat

Docker Cheat Sheet Travel Mug

Docker Cheat Sheet Travel Mug

Docker Cheat Sheet Mug

Docker Cheat Sheet Mug

Vim Cheat Sheet - Print at Home Designs

Vim Cheat Sheet - Print at Home Designs

Vim Cheat Sheet Mouse Mat

Vim Cheat Sheet Mouse Mat

Vim Cheat Sheet Travel Mug

Vim Cheat Sheet Travel Mug

Vim Cheat Sheet Mug

Vim Cheat Sheet Mug

SimpleSteps.guide branded Travel Mug

SimpleSteps.guide branded Travel Mug

Developer Excuse Javascript - Travel Mug

Developer Excuse Javascript - Travel Mug

Developer Excuse Javascript Embroidered T-Shirt - Dark

Developer Excuse Javascript Embroidered T-Shirt - Dark

Developer Excuse Javascript Embroidered T-Shirt - Light

Developer Excuse Javascript Embroidered T-Shirt - Light

Developer Excuse Javascript Mug - White

Developer Excuse Javascript Mug - White

Developer Excuse Javascript Mug - Black

Developer Excuse Javascript Mug - Black

SimpleSteps.guide branded stainless steel water bottle

SimpleSteps.guide branded stainless steel water bottle

Developer Excuse Javascript Hoodie - Light

Developer Excuse Javascript Hoodie - Light

Developer Excuse Javascript Hoodie - Dark

Developer Excuse Javascript Hoodie - Dark

© 2025 SimpleSteps.guide
AboutFAQPoliciesContact