Random Variables and PDFs
Pick one of the five flats at random. Its number of rooms is not fixed until you pick, but you can still say exactly how likely each value is. A number decided by chance is a random variable, and models describe their uncertainty with them all the time: "rent is probably around 20, give or take 4".
The rule
Discrete: probability sits on points. Continuous: probability is area under the density.
Discrete random variables take separate values you can list. Let be the rooms of a random flat from A to E. The rooms are 1, 2, 3, 2 and 2, so the probability mass function is:
| Rooms | 1 | 2 | 3 |
|---|---|---|---|
| Probability | 0.2 | 0.6 | 0.2 |
The probabilities sum to 1. The expected value is the probability-weighted average:
Continuous random variables can take any value in a range, like the exact rent of a flat in a new city. There are infinitely many possible values, so any single exact value has probability 0. Instead, a probability density function (PDF) is a curve, and the probability of landing in a range is the area under the curve over that range. The total area is 1.
Suppose rents in a new city are equally likely anywhere from 10 to 30 thousand. The density is flat, and to make the total area 1 over a width of 20, its height is . Then
A density is probability per unit, not a probability. So it can be bigger than 1: a density spread evenly from 0 to 0.5 must have height 2 to give area 1. The cumulative distribution function is the area to the left of , and it always climbs from 0 to 1.
The shortcut
Discrete: add the bars. Continuous: find the area (for a flat density, width times height).
Find the height
Range 10 to 30, width 20, so height 1/20 = 0.05.
The trap is reading a density's height as a probability. Height times width is what counts.
Drills
Answer fast — trust the rule.
For R, the rooms of a random flat from A to E, what is the expected value?
What is P(R ≥ 2)?
Rents are spread evenly from 10 to 30. What is P(12 ≤ rent ≤ 22)?
A density function has the value 2 at some point. Is that a mistake?
For a continuous rent, what is P(rent is exactly 20.000...)?
Remember
- Discrete: probability sits on points. Continuous: probability is area under the density.
- Shortcut: add the bars, or multiply width by height for a flat density.
- Trap: reading a density's height as a probability.
