Educerie · IB Diploma · Mathematics: analysis and approaches
IB Mathematics AA 4.14 · SL and HL
Discrete and continuous random variables
When a random variable takes a handful of values, or any value in an interval, how do you describe its centre and spread, and what happens to them when you change units?
What you will learn
HL Know how to find the mean, variance and standard deviation of a discrete random variable, and that a fair game has expected gain 0
HL Understand that a probability density function is never negative, has total area 1 and gives probabilities as areas, including piecewise ones
HL Know that the mode is where the density is greatest and the median splits the area in half
HL Understand how E(aX + b) and Var(aX + b) follow from E(X) and Var(X)
You must be able to
HL Calculate E(X), E(X squared) and Var(X) for a discrete table or a continuous density
HL Find an unknown constant in a density or a probability table
HL Find the mode and the median of a continuous random variable, including a piecewise one
HL Calculate probabilities from a density by integration
HL Use E(aX + b) = aE(X) + b and Var(aX + b) = a squared Var(X)
Find the fee that makes a game fair
In the exam. HL Paper 1 and Paper 2, often as a whole Section B question of 13 to 19 marks: find k (3 to 5 marks), a probability (2 to 3), the mode, median or mean (1 to 5 each), the variance (3 to 5), then E(aX+b) and Var(aX+b) (2 to 3). Paper 1 densities are integrated by hand and are not always polynomials (sin, arcsin and square roots appear), so substitution and integration by parts from Topic 5 matter. Paper 2 hands harder integrals and the median equation to the GDC, and sometimes puts a parameter in the density and asks for E(X) or Var(X) in terms of it. The unit also appears on HL Paper 3 (6 of the 43 examined parts on record). Paper 3 asks the same syllabus at length, so expect the constant, mean and variance of a density, possibly with a parameter, strung into one extended problem.
1Discrete random variables: mean and variance
Example: goals per match, X, for a football team.
x
0
1
2
3
4
P(X=x)
0.2
0.35
0.25
0.15
0.05
The expected value or mean is the probability-weighted average, E(X)=∑xP(X=x).
No match ends with 1.5 goals. The mean is the long-run average, the balance point in Figure 1.
Variance measures spread: the expected squared distance from the mean, Var(X)=E[(X−μ)2] with μ=E(X).
The booklet gives two versions:
Var(X)=∑(x−μ)2P(X=x)=∑x2P(X=x)−μ2, that is, Var(X)=E(X2)−[E(X)]2.
The second is nearly always faster. E(X2) = the expected value of the square: square each value, weight by its probability, add. More generally, E(g(X))=∑g(x)P(X=x) for any rule g.
The mode of a discrete variable is the value with the greatest probability. In Figure 1 it is 1.
E(X2)=3.5 is not [E(X)]2=2.25. The gap is the variance.
Variance is in goals2, so interpret the standard deviation, in goals. Figure 1 marks both.
Figure 1 · A discrete distribution, its mean and its spread
Example (Paper 1): the variable X has P(X=x)=x+1k for x∈{0,1,2}. Find k, E(X) and Var(X).
k(1+21+31)=611k=1, so k=116probabilities sum to 1E(X)=116(0+21+32)=116⋅67=117E(X2)=116(0+21+34)=116⋅611=1Var(X)=1−(117)2=121121−49=12172
Leave Paper 1 answers exact unless the question asks for decimals.
Example: a table can hide two probabilities. The total of 1 is one equation; a given mean is the second. Let P(X=x) be 0.1,a,b,0.4 for x=1,2,3,4, with E(X)=2.9.
0.1+a+b+0.4=1, so a+b=0.50.1+2a+3b+1.6=2.9, so 2a+3b=1.2b=1.2−2(0.5)=0.2 and a=0.3
Example: let P(X=0),P(X=1),P(X=2) be 0.61,a,a2.
The total gives a2+a−0.39=0, so a=0.3 or a=−1.3. A probability cannot be negative. Keep a=0.3 and say why you rejected the other root.
2Fair games and expected gain
Let X be a player's gain: the amount received minus the fee paid. The game is fair when E(X)=0.
Fair does not mean winning half the time. Nobody profits in the long run, because the fee equals the expected prize.
Example: a fairground stand sells a draw from a bag of eight tokens. One red pays $12, two blue pay $3, and five white pay nothing. Let W be the prize.
E(W)=12(81)+3(82)+0(85)=1.5+0.75=2.25
A fee of c gives an expected gain of 2.25−c.
The game is fair at c=$2.25.
At $3 the expected gain is −$0.75 per draw, the stand's profit.
Insurers and lotteries price the same way, with the customer's expected gain negative.
Spread of the prize: E(W2)=144(81)+9(82)=20.25, so Var(W)=20.25−2.252=15.1875. Section 7 shows the fee leaves it unchanged.
3Continuous random variables and the probability density function
A continuous variable has too many values to list. A probability density function (pdf)f(x) describes it, and area gives probability:
P(a≤X≤b)=∫abf(x)dx, with f(x)≥0 for all x and ∫f(x)dx=1 over all x (from −∞ to ∞).
A single point has zero area. So P(X<1)=P(X≤1) for a continuous variable, but not for a discrete one.
f(x) is a density, not a probability, so it can exceed 1. A variable spread evenly over [0,0.5] has f(x)=2 there.
Normally f is a formula on an interval and 0 elsewhere. Then "from −∞ to ∞" shrinks to that interval.
Example (Paper 1): finding k. A continuous random variable X has pdf f(x)=kx2(3−x) for 0≤x≤3, and f(x)=0 otherwise. Find k, then P(X<1).
∫03k(3x2−x3)dx=1k[x3−4x4]03=1k(27−481)=1k(427)=1, so k=274P(X<1)=274[x3−4x4]01=274(1−41)=274⋅43=91
Figure 2 shows the total area of 1 and the shaded 91.
On [0,3], x2≥0 and 3−x≥0, so f(x)≥0 too. "Show that f is a valid pdf" wants both checks.
Figure 2 · For a continuous variable, probability is area
For a probability between two limits, P(1<X<2)=274[(8−4)−(1−41)]=274⋅413=2713.
On Paper 2 the GDC gives 0.481 directly.
Example: let f(x)=ksinx for 0≤x≤3π and 0 otherwise. Angles are in radians.
k∫0π/3sinxdx=k[−cosx]0π/3=k(1−21)=2k=1, so k=2P(X<6π)=2[−cosx]0π/6=2(1−23)=2−3
Example: let f(x)=ax+b for 1≤x≤3 and 0 otherwise, with P(X>2)=0.6.
Two unknowns need two equations: total area 1, and given area 0.6.
∫13(ax+b)dx=4a+2b=1∫23(ax+b)dx=25a+b=0.6b=0.5−2a, so 2.5a+0.5−2a=0.6, giving a=0.2 and b=0.1
Check that f(x)=0.2x+0.1 is non-negative on [1,3]. A negative value anywhere on the interval rules the constants out.
Areas also give conditional probabilities: P(X>2.5∣X>2)=P(X>2)P(X>2.5)=0.60.325=2413.
A probability from a pdf can feed the binomial of 4.8. Observe six independent values and let Y count those above 2. Then Y∼B(6,0.6) and E(Y)=3.6.
Example: papers sometimes put a letter in the rule or the interval and expect answers in terms of it.
Let f(x)=k(a2−x2) for 0≤x≤a, where a>0. The area is k(a3−3a3)=32ka3=1, so k=2a33. Section 5 uses it.
4Mode and median of a continuous random variable
The guide defines both.
The mode is a value of x at which f(x) is at its maximum. Solve f′(x)=0 and show it is a maximum. If f rises or falls across the whole interval, take the endpoint and say so. Equal peaks in two places give two modes.
The medianm splits the area in half: ∫−∞mf(x)dx=21. The lower and upper quartiles use 41 and 43 instead. The interquartile range is Q3−Q1.
The accumulated areaF(x)=∫startxf(t)dt climbs from 0 to 1. The median is where it reaches 21.
Example: mode. For f(x)=274(3x2−x3):
f′(x)=274(6x−3x2)=274(3x)(2−x)f′(x)=0 when x=0 or x=2f(0)=0 and f(2)=274(4)(1)=2716, so the mode is 2
Justify the maximum. Either f′ changes from positive to negative at 2, or f(2) is bigger than f at the endpoints.
Example: median. Here you need 274[m3−4m4]=21, a quartic. It is a Paper 2 job.
274(m3−4m4)=21, with 0≤m≤3m=1.84 (3 s.f.)GDC solver, or intersect y=∫0xf(t)dt with y=0.5
Reject any GDC solution outside [0,3]. Figure 3 marks mode, median and mean (found in the next section) on the same curve.
Figure 3 · Mode, median and mean of the same density
Example (Paper 1): the median comes out exactly. For f(x)=2sinx on [0,π/3], the accumulated area is 2(1−cosm), so
2(1−cosm)=21, so cosm=43,m=arccos43=0.723 (3 s.f.)
This density has f′(x)=2cosx>0 on the interval, so it is increasing. The mode is the right-hand end, x=π/3. A mode need not be a stationary point.
5Mean, variance and standard deviation of a continuous random variable
Replace the sum by an integral and P(X=x) by f(x)dx:
E(X)=μ=∫xf(x)dx and Var(X)=∫(x−μ)2f(x)dx=∫x2f(x)dx−μ2, over all x. From the formula booklet.
So E(X2)=∫x2f(x)dx and again Var(X)=E(X2)−[E(X)]2. For f(x)=274(3x2−x3):
The x goes in before you integrate. ∫f(x)dx alone is just 1.
Figure 3 shows the mean 1.8 below the median 1.84, below the mode 2. Its inset stretches the small gap between mean and median.
The long tail runs left (negative skew). A tail pulls the mean more than the median, because the mean weights values by how far out they lie. A right tail reverses the order. A symmetric single-peak pdf has all three equal.
Use the order to check your numbers.
Example: for f(x)=2a33(a2−x2) on [0,a], treat a as a constant while integrating:
The density falls from x=0, so the mode is the endpoint 0. The median solves 3a2m−m3=a3, which for a=8 gives m=2.78 on the GDC. Mode < median < mean: a right tail.
Example: for f(x)=2sinx on [0,π/3], integrate by parts with u=x. This gives E(X)=2[−xcosx+sinx]0π/3=3−3π=0.685.
By GDC, E(X2)=0.531, so Var(X)=0.0620. The mode 1.05, median 0.723 and mean 0.685 show the left-tail order again.
Symmetry shortcut
Symmetry shortcut = if the graph of f is symmetrical about x=c, the mean and median are both c. So is the mode when there is one peak.
Exams ask you to "write down" these from the graph, with no integration. For the arch f(x)=43(1−x2) on [−1,1], all three are 0.
The variance still needs an integral: Var(X)=2⋅43∫01x2(1−x2)dx=51. Here μ=0, and doubling the half-integral uses the symmetry.
The quartiles of a symmetric pdf sit equally far either side of the centre.
6Piecewise probability density functions
The guide includes piecewise functions: one rule on one interval, another on the next. Every property stands. Each integral is split at the join.
A random variable X has
f(x)=6x for 0≤x≤2, f(x)=126−x for 2<x≤6, and f(x)=0 otherwise.
Figure 4 shows a triangle, rising in teal and falling in amber. Both rules give 31 at x=2, a useful check on a constant. A pdf may jump at the join.
Figure 4 · A piecewise density: two rules, one area of 1
Check it is valid. Both pieces are non-negative on their intervals, and
Mode: the highest point is the peak of the triangle, f(2)=31, so the mode is 2.
Median: the first piece holds only 31 of the area, less than 21. So the median lies in the second piece, and a further 21−31=61 is needed beyond x=2. Say which piece holds the median before integrating.