Date: 08/11/2025
Learn probability fundamentals, key events, Bayes’ theorem, and Python code examples in one guide.
Probability is a measure of the likelihood that a specific event will occur. It's a foundational concept in mathematics and statistics, widely used in data science, AI, finance, healthcare, and daily decision-making
The basic probability formula for Event(E) is:
P(E) = Number of Favorable Outcomes / Total Number of Possible Outcomes
Event(E):
An Event is a specific subset of the sample space - meaning it's one or more outcomes you are interested in.
For Example: By rolling a die you are looking for even numbers outcome. Then your event is
E = {2,4,6}
Experiment:
An experiment in probability is any action or process that can lead to different results, called outcomes.
Example: Tossing a coin, rolling a dice, or drawing a card are all experiments because each can result in different outcomes.
Sample Space (S):
All possible outcomes of an Experiment is called as Sample Space.
Example: Sample Space for a experiment rolling a die will be
S = {1,2,3,4,5,6}
Probability Range
Probability Range is value of occuring for the specific event which liies between 0 and 1
0 signifies that event is impossible or 0 % probability.
1 signifies that event is certain or 100% probability
if the value is 0.5 mean the event equally likely to occur or not (like flipping a coin)
Theoretical Probability
This is based on logical reasoning and known outcomes — assuming all outcomes are equally likely.
Formula
Example: The probability of getting "3" when rolling a fair six-sided die is :
P(3) = 1 /6 = 0.1666
Experimental Probability:
This is based on actual data or observations from repeated experiments. It measures how often an event happens out of many trials.
Formula
Example: If you toss a coin 100 times and get 52 times, the experimental probability of heads is:
P(head) = 52/100 = 0.52
Coin Toss : How Probability of Heads Changes Over Time
Flipping a coin is one of the simplest and most powerful examples of probability in action.
Theoretical Probability
A fair coin has two equally likely outcomes:
Heads (H)
Tails(T)
So, the theoretical probability of getting heads in any single toss is always:
P(Heads) = 1/2 = 0.5
Now lets see what happens when you toss the coin 2nd time.
The sample space extends to 4 outcome:
HH
HT
TH
TT
Out of above 4 outcomes. Now we have 3 favourable outcomes for at least one heads: HH, HT, TH
Thus, the probability of getting at least one heads is 3 out of 4. Which we can represent in
P(At least one H) = 3 / 4 = 0.75
This kind of relational or conditional probability we will disccuss in Basic Probability theory and in Events and Conditional Probability.
Understanding these four core types of events is essential when working with probability problems. Let’s break each down with simple definitions and examples, including coin toss scenarios to make them easier to grasp.
Two events are complementary if one event happening means the other cannot — together they cover the entire sample space.
Formula:
P(A') = 1 - P(A)
Example: Tossing a coin
Event A = Getting Heads
Complement A' = Getting Tails
Since there's no other option,
P(Tails)=1−P(Heads)=1−0.5=0.5
Two events are mutually exclusive if they cannot occur at the same time.
Example: Getting head and tails in one single toss which not possible
Event A = Getting Heads
Event B = Getting Tails
Since, both the events can't happen at same time they are mutually exclusive event and can be represented as P of A intersect B
P(A∩B) = 0
Events that can overlap or happen at the same time are called non-mutually exclusive.
Example: Getting head and tails in one single toss which not possible
Event A = Toss a coin twice and get at least one Head
Event B = Toss a coin twice and get at least one Tail
Outcomes like HT or TH satisfy both A and B
Conclusion: These events overlap and are not mutually exclusive.
Two events are independent if the outcome of one does not influence the other.
Example: Tossing a coin twice.
First toss = Heads
Second toss is still equally likely to be Heads or Tails
The result of the first toss doesn’t affect the second
Mathematically:
P(A∩B)=P(A)×P(B)(if A and B are independent)
Example Calculation:
P(Heads on Toss 1) = 0.5
P(Heads on Toss 2) = 0.5
P(Both Heads) = 0.5 × 0.5 = 0.25
Conditional probability is the likelihood of an event A happening given that another event B has already occurred.
Formula:
P(A∣B)= P(A∩B) / P(B)
How to Read This:
P(A | B) is read as: "The probability of A given B"
It tells us how probable A is, knowing that B has already happened.
Example: Disease Testing
Let’s say:
1% of a population has a disease
P(Disease) = 0.01
A test detects the disease correctly 90% of the time
P(Positive | Disease) = 0.90
Conditional probability is the likelihood of an event A happening given that another event B has already occurred.
Two Types of Probabilities:
P(Positive Test | Has Disease)
This is the sensitivity of the test:
P(Positive∣Disease)=0.90
P(Has Disease | Positive Test)
This is what most people want to know:
“If I test positive, do I actually have the disease?”
This is not 90% — because false positives exist and must be accounted for.
This is where Bayes Theorem comes in
To reverse the probability — like going from P(Positive | Disease) to P(Disease | Positive) — we use Bayes’ Theorem.
Formula:
P(A∣B) = P(B∣A)⋅ P(A) / P(B)
How to Read This:
"The probability of A given B equals the probability of B given A, multiplied by the probability of A, divided by the probability of B."
Applying Bayes’ Theorem to the Test Example:
(Disease) = 0.01
P(Positive | Disease) = 0.90
P(Positive | No Disease) = 0.05 (5% false positives)
P(No Disease) = 0.99
Step 1: Find Total Probability of Testing Positive (P(Positive))
P(Positive)=P(Positive∣Disease)⋅P(Disease)+P(Positive∣No Disease)⋅P(No Disease)
P(Positive)=0.90⋅0.01+0.05⋅0.99=0.009+0.0495=0.0585
Step 2: Use Bayes' Theorem
P(Disease∣Positive)= P(Positive∣Disease)⋅P(Disease)/P(Positive) = 0.90⋅0.01 / 0.0585 ≈0.1538
So even with a positive result, there's only about a 15.4% chance the person actually has the disease; because the condition is rare and false positives are possible.
Probability helps us make sense of uncertainty — from flipping coins to predicting diseases. By understanding experiments, events, conditional probability, and tools like Bayes’ Theorem, you build a solid foundation for more advanced topics. With Python, you can simulate, analyze, and apply probability to real-world data and decisions.
In our next blog, we’ll visually represent probabilities through:
Probability Trees: Great for multi-stage problems
Venn Diagrams: Perfect for overlapping events
Set Theory: The backbone of probability logic
Stay tuned to see how diagrams and logic can simplify complex calculations.
What is the easiest way to understand probability?
Use real-life scenarios like flipping coins, rolling dice, or weather forecasts to see how outcomes are predicted and measured.
How is probability used in real life?
In finance, gaming, medicine, AI predictions, traffic models, and weather forecasting.
What is conditional probability in simple terms?
It’s the chance of an event happening based on another event already occurring.
Can I use Python to calculate probability for real data?
Absolutely. Python is ideal for simulating events and analyzing probabilities in real-world datasets.
What’s the difference between theoretical and experimental probability?
Theoretical is based on possible outcomes; experimental is based on actual trials or data.