Probability

The medical test · simulation, Bayes, Monty Hall, spam

In this chapter, you will learn to

Tools: Python, NumPy

6 exercises

Each exercise is graded automatically, in your browser. The full statements are available once you have an account.

  1. What this is for in real life

    The world is uncertain, and all an AI ever does is reason with that uncertainty. - Language models. ChatGPT or Claude do not write a sentence in one go: at each step, they give a probability to every possible…

  2. Medical test

    You are a doctor. A patient is panicking: their screening test came back positive. You know 3 things about the test: - Prevalence: the fraction of the population that has the disease - Sensitivity: the…

  3. Lesson: the rules of probability

    The medical test had you handle, without naming them, the fundamental rules of probability. Conditional probability: P(A∣B)P(A \mid B) is the probability of AA given that BB is true (here…

  4. Monty Hall

    You are on a TV game show. In front of you, 3 doors. Behind one of them hides a car; behind the other two, goats. You pick a door (say door 1). The host, who knows where the car is, opens another door hiding a…

  5. Bayesian detective

    You are investigating a burglary. There are 3 suspects: Alice, Bob and Charlie. At the start, you have no reason to favor one over another: each has a "belief" of 1/3. Clue 1: A witness says the criminal wore a…

  6. Spam filter

    You get too much spam. You decide to build an automatic filter. You analyzed your old emails and recorded the frequency of certain words: | Word | Frequency in spam | Frequency in legitimate emails | |---|---|---| |…