AI Hints
Statistics & Math for ML · Lesson 25 of 138

What Is Probability?

From 0 to 1.

⏱ 2 min read▶ Video at 28:09🎓 Free
Watch this lesson in the Statistics & Math for ML courseWatch on YouTube ↗Full Statistics & Math for ML course

Will it rain tomorrow? Will this email turn out to be spam? Will this customer buy? Machine learning models rarely say yes or no. They say how likely. Probability is the language of how likely.

What Is Probability?
From the video: What Is Probability?
  • Rain? Spam? Buy?
  • Models say how likely
  • Probability

The basics

A probability is a number between zero and one. Zero means impossible, and one means certain. A half means fifty fifty, like a fair coin landing heads. When all outcomes are equally likely, the probability of an event is the number of ways it can happen, divided by the number of possible outcomes.

keyvalue
0impossible
1certain
0.5a fair coin
Equal outcomesways ÷ total

Rolling a die

A die has six equally likely faces. The probability of rolling a six is one out of six. The probability of an even number is three out of six, which is a half. And the probability of not rolling a six is one minus a sixth. Run it.

die.pypython
from fractions import Fraction

faces = [1, 2, 3, 4, 5, 6]
six = Fraction(1, len(faces))
even = Fraction(len([f for f in faces if f % 2 == 0]), len(faces))

print("P(six) =", six)
print("P(even) =", even)
print("P(not six) =", 1 - six)
Output
P(six) = 1/6
P(even) = 1/2
P(not six) = 5/6

Summary

Probability measures how likely something is, from zero to one. With equal outcomes, it's ways divided by total. Next, simulating chance with code.

Key takeaways
  • 0 impossible, 1 certain
  • ways ÷ total
  • P(not A) = 1 − P(A)
Next up: Simulating Chance — coins and dice in code