DSPython Logo DSPython

Binomial & Poisson Distributions

Master event-based probability modeling for discrete events - from Bernoulli trials to rare event analysis.

Discrete Probability Models Intermediate Level 40 min

🎯 Discrete Probability Distributions

Why These Distributions?

Binomial and Poisson distributions model count-based events in real-world scenarios.

They answer: "How many successes in n trials?" or "How many events in a time period?"

Real World Applications

  • Click-through rate prediction
  • Manufacturing defect analysis
  • Customer arrival modeling
  • Network failure prediction

πŸ“Š Distribution Comparison

B(n,p)

Binomial

Fixed trials, success/failure

vs
P(Ξ»)

Poisson

Rare events in time/space

Data Science Insight:
These distributions form the foundation for A/B testing, quality control, and reliability engineering in data science.

🎲 Bernoulli Trial

Definition

A Bernoulli trial is a random experiment with exactly two possible outcomes:

  • Success (with probability p)
  • Failure (with probability q = 1-p)

Properties

  • Only two outcomes
  • Probability p constant
  • Trials are independent
  • Example: Coin toss

Mathematical Model

X = {1 with probability p
0 with probability 1-p}

🎯 Real World Bernoulli Examples

🎯

Click Prediction

User clicks ad (p=0.02) or doesn't (0.98)

πŸ₯

Medical Test

Test positive (p=0.05) or negative (0.95)

🏭

Quality Check

Item defective (p=0.01) or good (0.99)

πŸ’°

Loan Default

Customer defaults (p=0.03) or pays (0.97)

πŸ“Š Bernoulli Distribution (p = 0.3)

q=0.7
Failure (0)
p=0.3
Success (1)
Expected Value: E[X] = p = 0.3 | Variance: Var(X) = p(1-p) = 0.21

πŸ”’ Binomial Distribution

πŸ“– What is Binomial Distribution?

B(n,p)
n trials, p success probability
Definition: Probability distribution of number of successes in n independent Bernoulli trials.

πŸ“ Binomial Probability Formula

P(X = k) = nCk Γ— pk Γ— (1-p)n-k
n
Number of trials
k
Number of successes
p
Success probability
nCk
Combinations

🎯 Example: Coin Toss

Scenario: Toss fair coin 5 times. What's probability of exactly 3 heads?
Parameters:
  • n = 5 (trials)
  • k = 3 (successes = heads)
  • p = 0.5 (probability of heads)
nCk
= 5C3 = 10
Γ—
pᡏ
= 0.5Β³ = 0.125
Γ—
(1-p)ⁿ⁻ᡏ
= 0.5Β² = 0.25
=
10 Γ— 0.125 Γ— 0.25 = 0.3125
P(3 heads in 5 tosses) = 31.25%

βœ… When to Use Binomial

  • Fixed number of trials (n)
  • Each trial has two outcomes
  • Constant probability (p)
  • Independent trials
  • Counting successes

❌ Not Binomial

  • Variable number of trials
  • More than two outcomes
  • Changing probability
  • Dependent trials
  • Continuous outcomes

πŸ“Š Binomial Distribution Properties

ΞΌ
Mean
np
σ²
Variance
np(1-p)
Οƒ
Std Dev
√[np(1-p)]
πŸ“ˆ
Shape
Symmetric if p=0.5

πŸ“ˆ Poisson Distribution

πŸ“– Modeling Rare Events

P(Ξ»)
Ξ» = average rate
Definition: Probability distribution of number of events occurring in a fixed interval of time/space, when events occur with known constant rate and independently.

πŸ“ Poisson Probability Formula

P(X = k) = (Ξ»k Γ— e-Ξ») / k!
Ξ» (lambda)
Average event rate
k
Number of events
e
Euler's number β‰ˆ 2.718
k!
k factorial

🎯 Example: Call Center

Scenario: Call center receives average 3 calls per hour. What's probability of exactly 5 calls in next hour?
Parameters:
  • Ξ» = 3 (average calls per hour)
  • k = 5 (events we want)
  • e = 2.71828 (Euler's number)
λᡏ
= 3⁡ = 243
Γ—
e⁻λ
= e⁻³ β‰ˆ 0.0498
/
k!
= 5! = 120
=
(243 Γ— 0.0498) / 120 β‰ˆ 0.1008
P(5 calls in hour) β‰ˆ 10.08%

βœ… When to Use Poisson

  • Events occur independently
  • Average rate (Ξ») is constant
  • Events are rare
  • Time/space based counting
  • No fixed number of trials

πŸ“‹ Real Examples

  • Website visits per minute
  • Emails received per hour
  • Manufacturing defects per day
  • Accidents per month
  • Customer arrivals per hour

πŸ“Š Poisson Distribution Properties

ΞΌ
Mean
Ξ»
σ²
Variance
Ξ»
Οƒ
Std Dev
√λ
πŸ“Š
Unique Property
Mean = Variance

βš–οΈ Binomial vs Poisson: When to Use Which?

πŸ“‹ Side-by-Side Comparison

Aspect Binomial Poisson
Type Counting successes in n trials Counting events in time/space
Parameters n (trials), p (success prob) Ξ» (average rate)
Trials Fixed number (n) Not fixed
Outcomes Success/Failure Event count
When to Use Yes/No questions, fixed trials Rare events, time-based

🎯 Decision Flowchart

Fixed number of trials?
↓ Yes
Only two outcomes?
↓ Yes
Use BINOMIAL
Counting events in time/space?
↓ Yes
Events independent & rare?
↓ Yes
Use POISSON

πŸ“Š Binomial β†’ Poisson Approximation

Rule: When n is large (n β‰₯ 20) and p is small (p ≀ 0.05), Binomial(n,p) β‰ˆ Poisson(Ξ» = np)

Binomial Example

n = 100, p = 0.02
P(X=3) using Binomial

Poisson Approximation

Ξ» = np = 100Γ—0.02 = 2
P(X=3) using Poisson(2)
πŸ’‘ Why it works: With large n and small p, events become rare β†’ Poisson applies

🧠 Data Science Applications

🎯

Click Prediction

Problem: Predict clicks on website banner
Binomial Approach:
  • n = 1000 impressions
  • p = 0.02 (historical CTR)
  • P(k clicks) = Binomial(1000, 0.02)
Business Use: Optimize ad placement based on expected clicks
⚠️

Failure Analysis

Problem: Server failures in data center
Poisson Approach:
  • Ξ» = 0.5 failures per day
  • Time period = 7 days
  • P(β‰₯3 failures) = 1 - P(0,1,2)
Business Use: Plan maintenance schedules, spare parts inventory
🏭

Quality Control

Problem: Defective items in manufacturing
Binomial
Batch sampling
Poisson
Continuous defects
Example: If 1% defect rate, what's P(≀2 defects in 100 items)?

🏒 Case Study: E-commerce Website

🎯 Problem

Predict conversion rate and server load

πŸ“Š Binomial Application

Conversion rate modeling:
P(purchase|visit) = 0.03
Expected purchases in 1000 visits

πŸ“ˆ Poisson Application

Visitor arrivals:
Ξ» = 50 visitors/hour
Probability of >60 visitors

Real Implementation:
β€’ Use Binomial for A/B testing (conversion rates)
β€’ Use Poisson for infrastructure planning (peak loads)

🎯 Interview Questions Preview

Q: When would you use Poisson instead of Binomial?
A: When events are rare, occur in time/space, and you don't have fixed number of trials (e.g., customer arrivals, defects)
Q: Hospital gets average 2 emergencies/hour. What's P(exactly 3 in next hour)?
A: Poisson with Ξ»=2, k=3: P(X=3) = (2Β³ Γ— e⁻²)/3! = (8 Γ— 0.1353)/6 β‰ˆ 0.1804 (18.04%)

βœ… Chapter Summary & Cheatsheet

🎲

Bernoulli Trial

Single trial, two outcomes, success probability p

E[X] = p, Var(X) = p(1-p)
πŸ”’

Binomial

n independent Bernoulli trials

P(X=k) = nCk pᡏ(1-p)ⁿ⁻ᡏ
πŸ“ˆ

Poisson

Rare events in time/space

P(X=k) = (λᡏ e⁻λ)/k!

⚑ Quick Decision Guide

Fixed trials β†’ Binomial Rare events β†’ Poisson nβ‰₯20, p≀0.05 β†’ Poisson approx Click rate β†’ Binomial Failure rate β†’ Poisson

πŸ“ Must-Know Formulas

Binomial
P(X=k) = nCk pᡏ(1-p)ⁿ⁻ᡏ
Poisson
P(X=k) = (λᡏ e⁻λ)/k!
Mean
Bin: np | Pois: Ξ»
Variance
Bin: np(1-p) | Pois: Ξ»
πŸ€–
DSPython AI Assistant βœ–
πŸ‘‹ Hi! I’m your AI assistant. Paste your code here, I will find bugs for you.