Probability Basics
Probability is a way of measuring how likely something is to happen. AI uses probability to handle uncertainty, compare possible outcomes, and make predictions.
Probability tells us how likely an event is to happen.
A probability can range from 0 to 1. A value closer to 1 means the event is more likely, while a value closer to 0 means it is less likely.
What Is Probability?
Probability measures the chance of something happening.
For example, imagine flipping a normal coin. There are two possible outcomes:
Heads Tails
Because both outcomes are equally likely:
Probability of Heads = 1 / 2 Probability of Tails = 1 / 2
In decimal form:
1 / 2 = 0.5
And as a percentage:
0.5 = 50%
Why Does AI Need Probability?
Real-world information is often uncertain. An AI model usually cannot know the correct answer with 100% certainty.
Instead of simply saying:
This email is spam.
an AI model can estimate:
Spam → 95% Not Spam → 5%
The model is expressing how confident it is about the possible outcomes.
This is one of the most important reasons probability is used in AI.
Probability Is Between 0 and 1
Probability is normally represented using a number between 0 and 1.
0 → Impossible 0.25 → Unlikely 0.50 → Equal chance 0.75 → Likely 1 → Certain
The same values can also be written as percentages.
0 = 0% 0.25 = 25% 0.50 = 50% 0.75 = 75% 1 = 100%
Impossible and Certain Events
A probability of 0 means an event cannot happen.
Probability = 0 Example: Rolling a 7 on a normal six-sided dice. Possible values: 1, 2, 3, 4, 5, 6 7 does not exist. Therefore: P(rolling 7) = 0
A probability of 1 means an event is certain to happen.
Probability = 1 Example: Rolling a number between 1 and 6 on a normal six-sided dice. P(number between 1 and 6) = 1
What Is an Event?
An event is something we are interested in happening.
For example, when rolling a dice:
Possible outcomes: 1 2 3 4 5 6
We could define an event as:
Event A = Rolling a 6
Another event could be:
Event B = Rolling an even number
The even outcomes are:
2, 4, 6
Basic Probability Formula
When all outcomes are equally likely, we can calculate probability using a simple formula.
Probability = Favorable Outcomes ------------------ Total Outcomes
For example, what is the probability of rolling a 6?
Favorable outcomes = 1 Total outcomes = 6 Probability = 1 / 6 Probability ≈ 0.167 Percentage ≈ 16.7%
Therefore, the probability of rolling a 6 is approximately 16.7%.
Another Simple Example
Suppose we have a bag containing 10 balls.
6 Red balls 4 Blue balls Total = 10 balls
What is the probability of picking a red ball?
Favorable outcomes = 6 Total outcomes = 10 Probability = 6 / 10 Probability = 0.6 Percentage = 60%
So there is a 60% probability of picking a red ball.
Probability in AI: Spam Detection
Now let's connect probability to AI.
Imagine an email contains words such as:
"Congratulations" "Winner" "Free" "Prize"
A machine learning model may recognize that these words frequently appear in spam emails.
The model might produce:
Spam → 0.92 Not Spam → 0.08
This means the model estimates a 92% probability that the email is spam.
The model can then use a rule such as:
If spam probability > 0.5
→ classify as Spam
This is a simplified example, but it shows how probability can be used to make an AI decision.
Probability as AI Confidence
Probability can also help us understand how strongly a model supports different possible answers.
Suppose an image classification model sees a picture of an animal.
Dog → 0.85 Cat → 0.10 Fox → 0.05
The model's most likely prediction is:
Dog → 85%
Notice that the model does not necessarily know with absolute certainty. It is assigning probabilities to possible outcomes.
Probability and Prediction
Many AI systems can be viewed as probability-based prediction systems.
Input ↓ AI Model ↓ Calculate probabilities ↓ Compare possible outcomes ↓ Choose likely outcome ↓ Prediction
For example, a customer recommendation system might estimate:
Product A → 70% Product B → 20% Product C → 10%
The system could recommend Product A because it has the highest estimated probability.
Probability Does Not Mean Certainty
This is an important concept.
If an AI model says:
Rain probability = 80%
it does not mean rain is guaranteed.
It means the model estimates that rain is highly likely based on the available information.
80% probability does NOT mean 100% certainty
AI often has to make decisions even when the available information is incomplete or uncertain.
Simple Python Example
Python can be used to represent and compare probabilities.
spam_probability = 0.92
if spam_probability > 0.5:
print("Spam")
else:
print("Not Spam")
Output:
Spam
This is not a machine learning model. It is simply showing how a probability value can be used in a decision.
Probability Values Must Make Sense
A probability cannot normally be negative or greater than 1.
Valid: 0 0.25 0.5 0.75 1 Invalid: -0.5 1.5 2
In AI, models often use special mathematical functions to convert raw model outputs into valid probabilities.
We will see some of these functions later when we study neural networks.
Probability and the Next Lessons
Probability Basics is the foundation for the rest of this Probability section.
Probability Basics
↓
How likely is an event?
Conditional Probability
↓
How likely is an event
given some information?
Probability Distributions
↓
How are many possible outcomes
represented?
Bayes' Theorem
↓
How do we update probability
when new evidence appears?
Understanding this progression is more important than memorizing formulas.
Probability is a mathematical way to represent uncertainty.
Probability ranges from 0 to 1. A value near 0 means an event is unlikely, while a value near 1 means it is likely. AI uses probability to handle uncertain information, compare possible outcomes, and make predictions.