Understand uncertainty, summarize data, and evaluate predictions.
Probability describes how likely something is to happen. Statistics helps us learn from collected information, called data. AI uses both to make predictions and check whether they are useful. You will also see how chatbots pick their next word with temperature and random sampling, and how image-generating AI learns to remove noise.
Free preview — no account needed. This is the Basic level of a Mathematical Foundations lesson from the AI Professional Series. The Intermediate and Advanced levels, with 20 more practice exercises and a Concept Quiz, are part of AI Professional. Optional practice only: it does not affect course totals, exams or certificates.
See AI Professional plansThis is the Basic level. There are 10 practice exercises, each with a hint and a full worked solution.
Start here if probability is new to you. Explore chance, averages, spread, and simple combinations of events.
An event is an outcome or group of outcomes we care about. Its probability is a number from 0 to 1: 0 means impossible and 1 means certain. Favourable outcomes are the ones that match the event. When all outcomes are equally likely, divide the number of favourable outcomes by the total number of outcomes.
In everyday words: Drawing a ticket from a well-mixed bag gives each ticket the same chance.
P(A) = favourable outcomes / total outcomesRead it as: The probability of event A equals the number of favourable outcomes divided by the total number of equally likely outcomes.
Worked example: A bag contains 3 blue tickets and 7 yellow tickets. What is the probability of drawing blue?
Answer: The probability is 0.3, or 30%.
Why it matters in AI: AI often reports a predicted probability rather than a definite answer. Understanding its scale helps you interpret that prediction.
The complement of an event means that the event does not happen. An event and its complement cover every possibility without overlap. Their probabilities therefore add to 1.
In everyday words: A delivery either arrives today or does not arrive today.
P(not A) = 1 − P(A)Read it as: The probability of not A equals one minus the probability of A.
Worked example: The probability that a parcel arrives today is 0.8. What is the probability that it does not?
Answer: The probability of not arriving today is 0.2, or 20%.
Why it matters in AI: For a prediction with exactly two possible outcomes, knowing one probability gives you the other.
The mean is the sum of the values divided by how many values there are. The median is the middle value after sorting; with two middle values, take their mean. The mode is the most frequent value. There can be several modes, or no single most frequent value.
In everyday words: Typical spending could mean your average bill, your middle bill, or the bill amount you see most often.
mean = sum of values / number of valuesRead it as: Add all the values, then divide by how many values there are.
Worked example: Find the mean, median, and mode of 2, 3, 3, 4, 8.
Answer: Mean = 4, median = 3, and mode = 3.
from statistics import mean, median, multimode
values = [2, 3, 3, 4, 8]
print(mean(values))
print(median(values))
print(multimode(values))Why it matters in AI: These summaries help you inspect training data. A very large value can pull the mean upward while leaving the median nearly unchanged.
Spread describes how far apart values are. The range is the largest value minus the smallest value. It is easy to calculate, but it ignores everything between those two values.
In everyday words: The difference between the hottest and coldest temperatures tells you how wide the day's temperature swing was.
range = largest value − smallest valueRead it as: Subtract the smallest value from the largest value.
Worked example: Daily order counts are 6, 9, 7, and 12. Find their range.
Answer: The range is 6 orders.
Why it matters in AI: Range gives a quick check for unusually large or small data values. It is a starting point, not a complete picture of variation.
Events are independent when knowing one happened does not change the probability of the other. AND means both events happen. OR means at least one happens, including the possibility that both happen. For independent events, multiply for AND; for OR, add their probabilities and subtract the overlap.
In everyday words: Two separate fair coin tosses do not influence each other. Getting heads on either toss includes getting heads on both.
P(A AND B) = P(A) × P(B); P(A OR B) = P(A) + P(B) − P(A) × P(B)Read it as: For independent events, multiply their probabilities for both. For at least one, add their probabilities and subtract their product.
Worked example: Two independent fair coins each have probability 0.5 of heads. Find the probability of two heads and of at least one head.
Answer: Two heads has probability 0.25. At least one head has probability 0.75.
Why it matters in AI: AI systems combine uncertain events. Multiplication is appropriate here only when the independence assumption is justified.
Try each one on paper first. Use the hint if you get stuck, then check the full solution.
Exercise 1. A bag has 2 red balls and 6 blue balls. What is the probability of drawing red?
Exercise 2. A fair six-sided die has faces numbered 1 through 6. What is the probability of rolling more than 4?
Exercise 3. The chance of rain is 0.35. What is the chance of no rain?
Exercise 4. Find the mean of 4, 6, and 8.
Exercise 5. Find the median of 9, 2, 4, and 7.
Exercise 6. Find the mode and range of 2, 2, 3, 5, and 8.
Exercise 7. For 1, 2, 2, 3, and 12, find the mean and median. Which is larger?
Exercise 8. Independent events A and B have probabilities 0.4 and 0.5. What is the probability of both?
Exercise 9. Independent events A and B have probabilities 0.4 and 0.5. What is the probability of at least one?
Exercise 10. Each of three independent sensors misses an object with probability 0.2. What is the probability that at least one sensor detects it?