Probability and Statistics 201-SN1-RE • CEGEP, Montreal

Revision sheet: discrete and continuous random variables (201-SN1-RE)

In this chapter, almost every mistake comes from the same confusion: treating a continuous variable as a discrete one, or the reverse.

What the sheet covers

In the discrete case, a probability is the height of a bar; in the continuous case, it is an area, and the height f(x)f(x) is only a probability per unit.

This sheet gathers the moves that earn the marks: normalizing a density with a correct integral, writing a cumulative distribution function piecewise, treating an improper integral as a limit, applying V(aX+b)=a2V(X)V(aX+b)=a^{2}V(X) without a linear reflex, and never confusing mode, median and expected value.

  • 9 mistakes that cost marks
  • 3 figures
  • 15 min reading
Do the chapter's exercises

The thread of the chapter

Discrete or continuous, a variable is read from its distribution: a probability is the HEIGHT of a bar in the discrete case, an AREA under the density in the continuous case. The density f(x)f(x) is therefore never a probability, and the expected value is not the most probable value.

Topics covered

  • Discrete random variable
  • Continuous random variable
  • Probability distribution
  • Cumulative distribution function
  • Expected value
  • Variance and standard deviation
  • Linear transformation of a variable
  • Probability density function
  • Normalizing constant
  • Median and quantiles
  • Continuous uniform distribution
  • Improper integral

The essentials

Bar or area: the distinction that governs everything

  • • DISCRETE: the values can be counted. The distribution gives P(X=xi)=pi≥0P(X=x_{i})=p_{i}\ge 0, with ∑pi=1\sum p_{i}=1. You ADD bar heights.
  • • CONTINUOUS: the values fill an interval. The distribution is a density f≥0f\ge 0 with total integral 11, and P(a≤X≤b)=∫abf(x) dxP(a\le X\le b)=\int_{a}^{b}f(x)\,dx. You INTEGRATE.
  • • Consequence: in the continuous case P(X=a)=0P(X=a)=0, so << and ≤\le give the same number; in the discrete case, P(X<a)P(X<a) and P(X≤a)P(X\le a) differ by the bar P(X=a)P(X=a).
  • • f(x)f(x) is measured in “probability per unit of xx”: over a small width hh, P(x≤X≤x+h)≈f(x) hP(x\le X\le x+h)\approx f(x)\,h.
12340.10.40.30.2discrete: P(X ≤ 2) = 0.1 + 0.400.510.75continuous: P(X ≥ 0.5) = areaf(x) = 2x
On the left, P(X≤2)P(X\le 2) is the sum of the two blue bars, 0.50.5; on the right, P(X≥0.5)P(X\ge 0.5) is the orange area under f(x)=2xf(x)=2x, 0.750.75, while the height f(1)=2f(1)=2 exceeds 11.

Write “X is continuous, so P(X = a) = 0” before changing a strict inequality into a non-strict one: the justification is often worth half a mark.

The same formulas, sum or integral

  • • Expected value: E(X)=∑xipiE(X)=\sum x_{i}p_{i} or E(X)=∫x f(x) dxE(X)=\int x\,f(x)\,dx. Variance: V(X)=E((X−μ)2)=E(X2)−E(X)2V(X)=E\big((X-\mu)^{2}\big)=E(X^{2})-E(X)^{2}, and σ(X)=V(X)\sigma(X)=\sqrt{V(X)}.
  • • Linear transformation: E(aX+b)=aE(X)+bE(aX+b)=aE(X)+b, V(aX+b)=a2V(X)V(aX+b)=a^{2}V(X), σ(aX+b)=∣a∣ σ(X)\sigma(aX+b)=|a|\,\sigma(X).
  • • Cumulative distribution function: F(x)=P(X≤x)F(x)=P(X\le x), increasing from 00 to 11. A staircase in the discrete case (each jump is a pip_{i}); continuous in the continuous case, with F′=fF'=f. Median: F(m)=0.5F(m)=0.5.
  • • Uniform distribution on [a,b][a, b]: f=1b−af=\frac{1}{b-a}, E=a+b2E=\frac{a+b}{2}, V=(b−a)212V=\frac{(b-a)^{2}}{12}.

On an infinite support, ∫0+∞\int_{0}^{+\infty} is an improper integral: integrate up to AA, then let AA tend to +∞+\infty.

The mistakes that cost marks

These are the errors I correct most often in session. Each one costs marks on a paper, even when the reasoning behind it is right.

1. Treating a strict inequality as a non-strict one for a discrete variable

the whole question

What not to write

“P(X<3)=P(X≤3)=0.8P(X<3)=P(X\le 3)=0.8.”

What to write

“XX is discrete: P(X<3)=P(X≤2)=0.5P(X<3)=P(X\le 2)=0.5, because the bar P(X=3)=0.3P(X=3)=0.3 is excluded.”

Why: The equality P(X<a)=P(X≤a)P(X<a)=P(X\le a) comes from P(X=a)=0P(X=a)=0, which holds only in the continuous case.

2. Rejecting a density because it exceeds 1

1 to 2 marks

What not to write

“f(x)=4f(x)=4 on [0,0.25][0, 0.25] is not a density, because a probability cannot exceed 11.”

What to write

“f≥0f\ge 0 and ∫00.254 dx=1\int_{0}^{0.25}4\,dx=1: it is a density. Only areas are capped at 11.”

0.250.50.75112345height 4: area 4 × 0.25 = 1height 1: area only 0.25xf(x)
The green density of height 44 has area 11: it is the right one. Capped at 11, the red height would cover an area of only 0.250.25.

Why: f(x)f(x) is a probability per unit: the shorter the support, the taller the density.

3. Applying a linear rule to the variance

2 marks

What not to write

“V(X)=4V(X)=4, so V(−3X+5)=−3×4+5=−7V(-3X+5)=-3\times 4+5=-7.”

What to write

“V(−3X+5)=(−3)2V(X)=36V(-3X+5)=(-3)^{2}V(X)=36 and σ(−3X+5)=3×2=6\sigma(-3X+5)=3\times 2=6.”

Why: A variance is a mean of squared deviations: the constant creates no deviation, and the factor acts squared. A negative variance always signals an error.

4. Rounding the expected value before computing the variance

1 mark

What not to write

“E(X)≈5.3E(X)\approx 5.3, E(X2)=29.49E(X^{2})=29.49, so V(X)=29.49−5.32=1.40V(X)=29.49-5.3^{2}=1.40.”

What to write

“E(X)=5.33E(X)=5.33 exactly, so V(X)=29.49−28.4089=1.0811V(X)=29.49-28.4089=1.0811.”

Why: E(X2)−E(X)2E(X^{2})-E(X)^{2} subtracts two large, close numbers: rounding E(X)E(X) by 0.030.03 throws the variance off by 30%30\%.

5. Forgetting the sign of the antiderivative when normalizing

the rest of the exercise

What not to write

“∫04(4−x)2 dx=[(4−x)33]04=−643\int_{0}^{4}(4-x)^{2}\,dx=\left[\frac{(4-x)^{3}}{3}\right]_{0}^{4}=-\frac{64}{3}, so k=−364k=-\frac{3}{64}.”

What to write

“An antiderivative of (4−x)2(4-x)^{2} is −(4−x)33-\frac{(4-x)^{3}}{3}, so the integral is 643\frac{64}{3} and k=364k=\frac{3}{64}.”

Why: The area under a positive curve is positive: a negative k gives a negative density and invalidates every probability that follows.

6. Giving the cumulative distribution function as a single piece

1 mark

What not to write

“F(x)=x316−3x4256F(x)=\frac{x^{3}}{16}-\frac{3x^{4}}{256} for every real xx.”

What to write

“F(x)=0F(x)=0 if x<0x<0; F(x)=x316−3x4256F(x)=\frac{x^{3}}{16}-\frac{3x^{4}}{256} if 0≤x≤40\le x\le 4; F(x)=1F(x)=1 if x>4x>4.”

Why: Outside the support, the polynomial formula gives nonsense (F(6)≈−1.69F(6)\approx -1.69, a negative “probability”); FF must stay between 00 and 11.

7. Replacing infinity by a number in an improper integral

1 mark for rigour

What not to write

“∫0+∞x e−x dx=[−(x+1)e−x]0∞=−(∞+1)e−∞+1\int_{0}^{+\infty}x\,e^{-x}\,dx=\left[-(x+1)e^{-x}\right]_{0}^{\infty}=-(\infty+1)e^{-\infty}+1.”

What to write

“∫0Ax e−x dx=1−(A+1)e−A\int_{0}^{A}x\,e^{-x}\,dx=1-(A+1)e^{-A}, and lim⁡A→+∞(A+1)e−A=0\lim_{A\to+\infty}(A+1)e^{-A}=0, so the integral converges and equals 11.”

Why: An improper integral is a limit: without writing the bound A and the limit, convergence is not justified.

8. Taking the expected value for the most probable value or the median

1 to 2 marks

What not to write

“For f(x)=x e−xf(x)=x\,e^{-x}, the most probable value is E(X)=2E(X)=2, and one observation in two exceeds 22.”

What to write

“The mode is 11 (maximum of ff), the median about 1.681.68, the expected value 22; and P(X>2)=3e−2≈0.41P(X>2)=3e^{-2}\approx 0.41.”

123456780.10.20.30.40.5mode 1median ≈ 1.68E(X) = 2P(X > 2) ≈ 0.41xf(x)
For f(x)=x e−xf(x)=x\,e^{-x}, the three markers separate: mode 11, median 1.681.68, expected value 22; the orange area, to the right of the expected value, is only 0.410.41.

Why: As soon as the density is skewed, mode, median and expected value separate; the long tail pulls the expected value toward its side.

9. Believing that a bias correction reduces the spread

1 mark

What not to write

“By subtracting 0.050.05 from the error ε\varepsilon of each measurement, the error becomes smaller: σ\sigma decreases.”

What to write

“σ(ε−0.05)=σ(ε)\sigma(\varepsilon-0.05)=\sigma(\varepsilon): the correction makes the measurement accurate on average, it does not make it more precise.”

Why: A shift moves the whole distribution without narrowing it: that is V(X + b) = V(X).

Which method to choose

Which tool for which question

First check whether the variable is discrete or continuous, then what the problem asks for.

  • If P(X=a)P(X=a), continuous variable → the answer is 0, with no calculation

    Example: P(D=2)=0P(D=2)=0 for a diameter

  • If P(a≤X≤b)P(a\le X\le b), discrete variable → add the bars, reading each endpoint: included or excluded

    Example: P(4<X≤6)=P(X=5)+P(X=6)P(4<X\le 6)=P(X=5)+P(X=6)

  • If P(a≤X≤b)P(a\le X\le b), continuous variable → F(b)−F(a)F(b)-F(a) if FF is known, otherwise ∫abf(x) dx\int_{a}^{b}f(x)\,dx

    Example: F(1.5)−F(0.5)F(1.5)-F(0.5)

  • If an unknown constant in the density → write that the total integral equals 1, then check non-negativity

    Example: k∫03x2 dx=1k\int_{0}^{3}x^{2}\,dx=1 gives k=19k=\frac{1}{9}

  • If a median, a quartile, a p percent threshold → solve F(m)=pF(m)=p; if the equation is transcendental, bracket it with the intermediate value theorem

    Example: F(8.3)<0.5<F(8.4)F(8.3)<0.5<F(8.4)

  • If E(aX+b)E(aX+b) or V(aX+b)V(aX+b) → the properties, without recomputing the distribution

    Example: V(2.5X+1)=6.25 V(X)V(2.5X+1)=6.25\,V(X)

  • If an integral of xne−x/ax^{n}e^{-x/a} → integration by parts, differentiating the power of x

    Example: ∫0Ax e−x/5 dx=25−(5A+25)e−A/5\int_{0}^{A}x\,e^{-x/5}\,dx=25-(5A+25)e^{-A/5}

    on an infinite support, finish with the limit as A tends to infinity

No branch applies? Go back to the definitions: E(X)=∫x f(x) dxE(X)=\int x\,f(x)\,dx and F(x)=∫−∞xf(t) dtF(x)=\int_{-\infty}^{x}f(t)\,dt.

How the answer is expected to be written

A marker ticks steps. Here they are in order, with the concluding sentence expected word for word.

Proving the computational formula of the variance

When to use it: “Show that V(X)=E(X2)−E(X)2V(X)=E(X^{2})-E(X)^{2}” (discrete or continuous).

  1. 1 Let μ=E(X)\mu=E(X) and start from the definition V(X)=E((X−μ)2)V(X)=E\big((X-\mu)^{2}\big).
  2. 2 Expand the square: (x−μ)2=x2−2μx+μ2(x-\mu)^{2}=x^{2}-2\mu x+\mu^{2}.
  3. 3 Split the sum (or the integral) into three, taking out μ\mu, which is a fixed number.
  4. 4 Use ∑pi=1\sum p_{i}=1 (or ∫f=1\int f=1) and ∑xipi=μ\sum x_{i}p_{i}=\mu: you get E(X2)−2μ2+μ2E(X^{2})-2\mu^{2}+\mu^{2}.

Concluding sentence

“Therefore V(X)=E(X2)−2μ2+μ2=E(X2)−E(X)2V(X)=E(X^{2})-2\mu^{2}+\mu^{2}=E(X^{2})-E(X)^{2}.”

The trap: Not citing ∑pi=1\sum p_{i}=1 when the term μ2∑pi\mu^{2}\sum p_{i} becomes μ2\mu^{2}: that is the step the grader looks for.

Marking: Expansion 1 mark, linearity 1 mark, use of the normalization 1 mark.

Checking that a function is a density and finding its constant

When to use it: “Find kk so that ff is a density” or “Show that ff is a density”.

  1. 1 Write the non-negativity, with its reason: sign of each factor on the support, and f equal to zero elsewhere.
  2. 2 Compute the integral over the support, with the antiderivative written out in full.
  3. 3 Set the integral equal to 1 and isolate the constant.
  4. 4 Check: the constant is positive, and a simple value of f is plausible.

Concluding sentence

“f≥0f\ge 0 and ∫−∞+∞f(x) dx=1\int_{-\infty}^{+\infty}f(x)\,dx=1: ff is a probability density function.”

The trap: Forgetting non-negativity: the area condition alone is not enough, a function that changes sign can have an integral equal to 1.

Check before you hand in

Five minutes of checking recover more marks than one more problem started in a hurry.

  • The sum that makes 1

    Add the probabilities of a discrete distribution, or integrate the density found over the whole support (TI: fnInt; Casio: the integral key of the RUN menu).

    A distribution that adds up to 0.950.95 has lost a value; a density whose integral is 22 has kept one factor too many.

  • The expected value inside the support, the variance positive

    E(X)E(X) falls between the smallest and the largest possible value; V(X)≥0V(X)\ge 0, and σ\sigma is of the same order as the spread of the values.

    An expected value of 4.74.7 for a density on [0,4][0, 4], or V=−0.3V=-0.3, signals a calculation error.

  • The cumulative distribution function at the endpoints

    FF equals 00 at the start of the support and 11 at the end, and it increases in between. For a median, plug mm back into FF.

    F(4)=0.98F(4)=0.98 for a distribution on [0,4][0, 4] says the antiderivative is wrong; F(m)=0.502F(m)=0.502 confirms a median to two decimal places.

  • The order mode, median, expected value

    Compare the three with the shape of the density: tail on the right, the expected value is the largest; tail on the left, the smallest.

    A density that rises gently and drops quickly must have an expected value below its mode; otherwise, go over the calculation again.

The typical problem, taken apart

Depth at which a squirrel buries an acorn

A squirrel buries acorns at a depth XX, in centimetres, modelled by the density f(x)=k x2(4−x)f(x)=k\,x^{2}(4-x) on [0,4][0, 4], zero elsewhere.

Find kk, compute P(X≥2)P(X\ge 2), the expected value, the standard deviation and the mode, then place the expected value relative to the mode.

Step 1

On [0,4][0, 4], x2≥0x^{2}\ge 0 and 4−x≥04-x\ge 0: f≥0f\ge 0 as soon as k>0k>0. ∫04(4x2−x3) dx=[4x33−x44]04=2563−64=643\int_{0}^{4}(4x^{2}-x^{3})\,dx=\left[\frac{4x^{3}}{3}-\frac{x^{4}}{4}\right]_{0}^{4}=\frac{256}{3}-64=\frac{64}{3}, so k=364k=\frac{3}{64}.

Why

Non-negativity, then the total area: the two conditions of a density, written in this order, are each worth marks.

Step 2

F(x)=364(4x33−x44)=x316−3x4256F(x)=\frac{3}{64}\left(\frac{4x^{3}}{3}-\frac{x^{4}}{4}\right)=\frac{x^{3}}{16}-\frac{3x^{4}}{256} on [0,4][0, 4]; F(2)=816−48256=0.3125F(2)=\frac{8}{16}-\frac{48}{256}=0.3125, so P(X≥2)=0.6875P(X\ge 2)=0.6875.

Why

Once F is written, each probability is read with one subtraction; a strict or non-strict sign changes nothing, X is continuous.

Step 3

E(X)=364∫04(4x3−x4) dx=364(256−10245)=364×2565=2.4E(X)=\frac{3}{64}\int_{0}^{4}(4x^{3}-x^{4})\,dx=\frac{3}{64}\left(256-\frac{1024}{5}\right)=\frac{3}{64}\times\frac{256}{5}=2.4 cm.

Why

Multiply the density by x BEFORE integrating: it is the weighted average of the discrete case, the sum turned into an integral.

Step 4

E(X2)=364∫04(4x4−x5) dx=364(40965−40966)=6.4E(X^{2})=\frac{3}{64}\int_{0}^{4}(4x^{4}-x^{5})\,dx=\frac{3}{64}\left(\frac{4096}{5}-\frac{4096}{6}\right)=6.4; V(X)=6.4−5.76=0.64V(X)=6.4-5.76=0.64; σ(X)=0.8\sigma(X)=0.8 cm.

Why

The computational formula of the variance, with E(X) exact: no rounding before the subtraction.

Step 5

f′(x)=364(8x−3x2)=3x(8−3x)64f'(x)=\frac{3}{64}(8x-3x^{2})=\frac{3x(8-3x)}{64} vanishes at x=83≈2.67x=\frac{8}{3}\approx 2.67: this is the mode.

Why

The mode is a maximum of f, found by differentiation like any extremum.

Step 6

Check: F(4)=4−3=1F(4)=4-3=1, E(X)=2.4∈[0,4]E(X)=2.4\in[0, 4], and E(X)=2.4<E(X)=2.4< mode 2.672.67: the density is skewed toward shallow depths.

Why

The endpoint check and the order of the centres take ten seconds and catch a wrong antiderivative.

The conclusion, written out

k=364k=\frac{3}{64}, P(X≥2)=0.6875P(X\ge 2)=0.6875, E(X)=2.4E(X)=2.4 cm, σ(X)=0.8\sigma(X)=0.8 cm, mode 83\frac{8}{3} cm: the most frequent depth exceeds the mean depth, because a few acorns stay almost at the surface.

The classic mistake on this problem: Taking E(X)E(X) for the midpoint of the support, 22 cm, or for the mode, 2.672.67 cm: here the expected value lies between the two and cannot be guessed.

Learn by heart

  • • Discrete: you SUM bars. Continuous: you INTEGRATE a density, and P(X=a)=0P(X=a)=0.
  • • Density: f≥0f\ge 0 AND total integral equal to 11; its value can exceed 11.
  • • V(X)=E(X2)−E(X)2V(X)=E(X^{2})-E(X)^{2}, with E(X)E(X) EXACT; a variance is never negative.
  • • E(aX+b)=aE(X)+bE(aX+b)=aE(X)+b; V(aX+b)=a2V(X)V(aX+b)=a^{2}V(X); σ(aX+b)=∣a∣ σ(X)\sigma(aX+b)=|a|\,\sigma(X).
  • • F(x)=P(X≤x)F(x)=P(X\le x) is given PIECEWISE: 00 before the support, 11 after. Median: F(m)=0.5F(m)=0.5.
  • • Uniform distribution on [a,b][a, b]: E=a+b2E=\frac{a+b}{2}, V=(b−a)212V=\frac{(b-a)^{2}}{12}.
  • • Mode, median and expected value are three different numbers as soon as the density is skewed.

Frequently asked questions

How do you tell whether a random variable is discrete or continuous?

Ask whether its values can be counted. A number of eggs, mutations or days is discrete: between two neighbouring values, there is no other one. A duration, a distance or a diameter measured without rounding is continuous: between two values, there is always a third. The same quantity can become discrete if it is only observed at fixed intervals, for example once a day.

Why can a probability density exceed 1?

Because the density is not a probability: it is a probability per unit of the variable. The only constraint is that the total area under the curve equals 1. A uniform distribution on an interval of length 0.25 has a density equal to 4, and the area is indeed 4 times 0.25, that is 1. It is the areas, hence the probabilities, that never exceed 1.

How do you compute the expected value of a continuous random variable?

Integrate x times the density over the whole support. It is the weighted average of the discrete case, where the sum of the values multiplied by their probabilities becomes an integral. On an infinite support, the integral is improper: integrate up to a bound A, often by parts, then take the limit as A tends to infinity.

What is the difference between the expected value, the median and the mode?

The mode is the value where the density, or the bar, is highest. The median splits the probability into two halves: it is found by solving F of m equals 0.5. The expected value is the weighted average, the average value over a large number of repetitions. For a density skewed to the right, the usual order is mode, then median, then expected value, and fewer than half of the values exceed the expected value.

Why is the variance of aX + b equal to a squared times the variance of X?

Adding b shifts every value by the same amount, without changing their deviations from the mean: the variance does not move. Multiplying by a multiplies each deviation by a, hence each squared deviation by a squared. Since the variance is the mean of these squares, it is multiplied by a squared, and the standard deviation by the absolute value of a.

Mark this sheet as read or add it to your favourites: a free account, no password, keeps your read sheets and favourites from one visit to the next, tells you which chapter to tackle next and lets you ask for the method or exercise you are missing. Create your space, an email is enough.

Practise it

Corrected exercises: Discrete and continuous random variables, 201-SN1-RE

A method is proved on a paper, not on a sheet. The set for the same chapter takes each of these traps into a problem, with the solution written out step by step.

  • 11 corrected exercises
  • 110 points
  • 180 minutes
Do the exercises
Something missing from this sheet? A method, a trap, an exercise to practise it, a mistake you spotted: tell me, I read every request.

Sending goes through your free space: that is how I can answer you and tell you when the exercise is added. An email is enough, no password. Create your space. Rather not create an account? Write to me directly.

What is it about?
I read every request myself, nobody else sees it. No need to write your name or your school.
When your request is dealt with, you hear about it by email and in your space.

By sending, you agree that I read your request to answer it. It is kept with your account, erased with it, and never published: privacy policy.

This chapter comes back in

The chapters that build on it, later in the year or in the years that follow.

© Ahmed Squalli Houssaini. Revision sheet published at www.letuteurscientifique.ca/en/fiches/cegep-sn1-random-variables. Free for personal and classroom use; republishing it elsewhere requires written permission (legal notice).

Looking for a 201-SN1-RE tutor in Montreal?

Get in touch for a first session. Random variables are the chapter where integral calculus meets probability: marks are lost by reading a density as a probability far more often than by integrating.

Site by Studio Squalli