9. Probability Basics & Conditional Probability
1. Concept Overview
In Data Science, nothing is certain. We predict "80% chance of rain" or "90% chance this email is spam."
Discrete Probability deals with countable outcomes (like coin flips, dice rolls, or word counts). This is the engine behind Naive Bayes classifiers and Random Forests.
2. Intuition (The "Bucket" Analogy)
-
Sample Space (S): The bucket containing every possible outcome.
-
Event (E): A scoop from the bucket containing just the specific outcomes you care about.
-
Probability (P): The weight of your scoop divided by the weight of the full bucket.
3. Formal Definitions
-
Sample Space (S): The set of all possible outcomes.
-
Example: Tossing a coin twice. S = \{HH, HT, TH, TT\}. |S| = 4.
-
Event (E): A subset of the sample space (E \subseteq S).
-
Example: Getting at least one Head. E = \{HH, HT, TH\}.
-
Probability of an Event (P(E)):
P(E) = \frac{\text{Number of favorable outcomes}}{\text{Total number of possible outcomes}} = \frac{|E|}{|S|}(Assuming all outcomes are equally likely).
4. The Rules of Probability
| Rule | Formula | Intuition |
| Sum Rule | P(A \cup B) = P(A) + P(B) - P(A \cap B) | Don't count the overlap twice! (Inclusion-Exclusion). |
| Complement | P(A^c) = 1 - P(A) | The chance of it not happening. |
| Mutually Exclusive | If A \cap B = \emptyset, then P(A \cup B) = P(A) + P(B) | They can't both happen (e.g., Rolling a 2 AND a 5 at once). |
6. Independence
Two events are Independent if knowing one happened gives you zero information about the other.
Definition: Events A and B are independent if:
- Example: Tossing a coin (H) and rolling a die (6). The coin landing on Heads doesn't change the luck of the die.
7. Worked Examples
Example 1: Basic Coin Toss (Easy)
-
Experiment: Toss a coin 3 times.
-
Question: What is the probability of getting exactly 2 Heads?
-
Step 1: Find Sample Space S.
-
\{HHH, HHT, HTH, HTT, THH, THT, TTH, TTT\}.
-
|S| = 8.
-
Step 2: Find Event E (Exactly 2 Heads).
-
\{HHT, HTH, THH\}.
-
|E| = 3.
-
Step 3: Calculate.
-
P(E) = 3/8.
Example 2: Conditional Probability (Medium)
-
Scenario: You roll two dice (Red and Blue).
-
Event B: The sum is 6. (B = \{(1,5), (2,4), (3,3), (4,2), (5,1)\}). |B|=5.
-
Event A: The Red die is a 2.
-
Question: Find P(A | B) (Prob. Red is 2 GIVEN Sum is 6).
-
Solution:
-
Formula: P(A \cap B) / P(B).
-
A \cap B: The pair must sum to 6 AND Red is 2. Only one option: \{(2, 4)\}.
-
P(A \cap B) = 1/36.
-
P(B) = 5/36.
-
P(A | B) = \frac{1/36}{5/36} = \frac{1}{5}.
-
Intuitive Check: Look at set B (5 items). Only one of them starts with 2. So 1/5.
Example 3: Independence Check (Challenging)
-
Scenario: Pick a card from a deck of 52.
-
A: Card is an Ace. (4 Aces). P(A) = 4/52 = 1/13.
-
H: Card is a Heart. (13 Hearts). P(H) = 13/52 = 1/4.
-
Question: Are "Ace" and "Heart" independent?
-
Test: Does P(A \cap H) = P(A) \cdot P(H)?
-
P(A \cap H): Probability of "Ace of Hearts". There is only 1. So 1/52.
-
P(A) \cdot P(H) = (1/13) \cdot (1/4) = 1/52.
-
Conclusion: Yes, 1/52 = 1/52. They are Independent.
-
Meaning: Knowing a card is a Heart doesn't make it more or less likely to be an Ace.
8. Common Mistakes
-
Confusing Mutually Exclusive with Independent:
-
Mutually Exclusive: If A happens, B cannot happen. (Highly dependent! Knowing A tells you B is impossible).
-
Independent: If A happens, B is unaffected.
-
Adding probabilities wrongly: P(A \cup B) \neq P(A) + P(B) unless they are exclusive. Always subtract the overlap!
9. Data Science Connection
-
Naive Bayes Classifier: It assumes features are Independent to simplify calculation:
P(Spam | \text{"Buy", "Now"}) \propto P(\text{"Buy"} | Spam) \cdot P(\text{"Now"} | Spam) \cdot P(Spam) -
A/B Testing: We use probability distributions to see if a change in a website actually caused more clicks or if it was just random chance.
This covers the core of Probability.
We have covered the most critical parts of the syllabus for your exam.
Would you like a "Cheat Sheet" summary of all the formulas we covered today for your last-minute revision?
**
Tags: #math #statistics