Skip to the workspace
Pebellslearn by building
Probability  ›  Lesson

Basics of Probability

Basics of Probability 14 minA probability is favourable outcomes over total outcomes, with rules for not, or, and, and for conditions that shrink the set you count in.

machine learning / Basics of Probability

Explore each scene at your own pace.

01 · The rule

The rule

Basics of Probability

A classifier that says "70% chance this flat rents within a week" is speaking the language of probability. Before trusting such a number, you need to know what it means and how probabilities combine. This month the agency listed 20 flats and recorded two facts about each:

Rented within a week Took longer Total
Near the metro 6 2 8
Far from the metro 6 6 12
Total 12 8 20

The rule

Count favourable over total; add for OR, subtract overlap; multiply for AND.

When every flat is equally likely to be picked, a probability is a count divided by a count.

  • Single event: P(fast)=12/20=0.6P(\text{fast}) = 12/20 = 0.6.
  • Complement: P(not fast)=1−0.6=0.4P(\text{not fast}) = 1 - 0.6 = 0.4.
  • AND: P(near and fast)=6/20=0.3P(\text{near and fast}) = 6/20 = 0.3, the one cell where both hold.
  • OR: P(near or fast)=0.4+0.6−0.3=0.7P(\text{near or fast}) = 0.4 + 0.6 - 0.3 = 0.7. The overlap is subtracted because the 6 near-and-fast flats were counted in both terms. Counting directly: 8 near plus the 6 far-and-fast flats makes 14 out of 20.
  • Conditional: P(fast∣near)P(\text{fast} \mid \text{near}) means "among near flats only". That is 6/8=0.756/8 = 0.75.
  • Multiplication rule: P(A and B)=P(A)×P(B∣A)P(A \text{ and } B) = P(A) \times P(B \mid A). Check: 0.4×0.75=0.30.4 \times 0.75 = 0.3.

Two events are independent when knowing one does not change the other: P(B∣A)=P(B)P(B \mid A) = P(B). Here P(fast∣near)=0.75P(\text{fast} \mid \text{near}) = 0.75 but P(fast)=0.6P(\text{fast}) = 0.6, so metro distance tells you something. That is exactly what makes it a useful feature. Only for independent events can you multiply the plain probabilities: two unrelated flats from different months, each with a 0.6 chance, both rent fast with probability 0.6×0.6=0.360.6 \times 0.6 = 0.36.

Scene 1 of 5
Hover to wake the cannons. Drag to move, or use arrow keys when focused. Press Enter to fire a shot.