Weeks
Statistics 2Week 4 · Continuous Random Variables, Density Functions and Expectations
Week 4 Notes

Statistics for
Data Science 1

Continuous random variables: discrete versus continuous, the CDF and its jumps, density functions, probability and percentiles from a PDF, conditional probability, the uniform and exponential distributions, and expectations, with every worked question solved.

8 chapters~19 min read
CDFDensity functionsPercentilesExpectations

Chapters

  1. 01Discrete, Continuous and the CDFDiscrete and continuous
  2. 02Jumps in a CDFDiscrete and continuous
  3. 03The CDF of a Continuous VariableContinuous variables
  4. 04Density FunctionsContinuous variables
  5. 05Probability from a PDF and PercentilesContinuous variables
  6. 06Conditional Probability, Uniform and ExponentialContinuous variables
  7. 07Expectations, Mean and VarianceExpectations
  8. 08Week 4 Summary SheetSummary
01
Discrete and continuous

Discrete, Continuous and the CDF

Discrete
  • A discrete variable takes countable values and has a PMF.
Continuous
  • When a quantity takes many distinct values, we model it as continuous and ask about intervals.
Steps → discreteSmooth → continuousJump + smooth → mixed
Figure 1. The shape of the CDF tells the type: steps are discrete, a smooth curve is continuous, a jump plus a smooth part is mixed

1.1CDF and interval probability

Definition: CDFThe cumulative distribution function (CDF) adds up all the probability up to xx:
FX(x)=P(X≤x)F_X(x) = P(X \le x)
Between two values
P(a<X≤b)=F(b)−F(a)P(a < X \le b) = F(b) - F(a)
Above a value
P(X>a)=1−F(a)P(X > a) = 1 - F(a)
  • The CDF never decreases, starts from 0 and ends at 1.

1.2Worked questions

Question 1: daily rainfall

The CDF of the daily rainfall XX (in mm) is F(x)=1−e−0.5xF(x) = 1 - e^{-0.5x} for x≥0x \ge 0. Find the probability that the rainfall exceeds 10 mm.

P(X>10)=1−F(10)=1−(1−e−0.5(10))=e−5≈0.0067P(X > 10) = 1 - F(10) = 1 - \left(1 - e^{-0.5(10)}\right) = e^{-5} \approx 0.0067

Question 2: a piecewise CDF with an unknown k

The CDF of a random variable XX is below. If P(X≤4)=34P(X \le 4) = \frac{3}{4}, find P(1≤X≤5)P(1 \le X \le 5).

F(x)={0x<0kx240≤x<2k+x−282≤x<61x≥6F(x) = \begin{cases} 0 & x < 0 \\ \dfrac{kx^2}{4} & 0 \le x < 2 \\ k + \dfrac{x - 2}{8} & 2 \le x < 6 \\ 1 & x \ge 6 \end{cases}
  1. Pick the right piece. x=4x = 4 lies in 2≤x<62 \le x < 6, so F(4)=k+4−28=k+14F(4) = k + \frac{4 - 2}{8} = k + \frac{1}{4}.
  2. Use the given value. k+14=34k + \frac{1}{4} = \frac{3}{4}, so k=34−14=12k = \frac{3}{4} - \frac{1}{4} = \frac{1}{2}.
  3. Interval probability. P(1≤X≤5)=F(5)−F(1)P(1 \le X \le 5) = F(5) - F(1). Here F(5)=k+5−28=12+38=78F(5) = k + \frac{5 - 2}{8} = \frac{1}{2} + \frac{3}{8} = \frac{7}{8} and F(1)=k4=18F(1) = \frac{k}{4} = \frac{1}{8}.
  4. So P(1≤X≤5)=78−18=68=34P(1 \le X \le 5) = \frac{7}{8} - \frac{1}{8} = \frac{6}{8} = \frac{3}{4}.
-10123456700.250.50.751F(1) = 1/8F(5) = 7/8F(4) = 3/4xy
Figure 2. The CDF of Question 2 with k = 1/2: it never decreases, starts at 0 and ends at 1. P(1 ≤ X ≤ 5) is the rise from F(1) = 1/8 to F(5) = 7/8
The fill-in-the-blanks versionThe original question asks for the blanks A to F with option numbers: A = k+14k + \frac{1}{4}, B = 12\frac{1}{2}, C = X≤5X \le 5, D = 78\frac{7}{8}, E = 18\frac{1}{8}, F = 34\frac{3}{4}. That is exactly the working above.

1.3Going deeper

  1. Check the pieces join up. At x=2x = 2: kx24=k\frac{kx^2}{4} = k and k+2−28=kk + \frac{2-2}{8} = k. At x=6x = 6: k+48=1k + \frac{4}{8} = 1 also gives k=12k = \frac{1}{2}. Two different conditions give the same kk.
  2. Which piece? Always find which interval xx falls in before substituting.
  3. Less than and at most. P(X>a)=1−F(a)P(X > a) = 1 - F(a) because the whole probability is 1 and F(a)F(a) is the part up to aa.
Exam tips
  • Write which piece of the CDF you use before substituting.
  • Check that the answer is between 0 and 1.
Common mistakes
  • Using the wrong piece of the CDF.
  • Writing P(X>a)=F(a)P(X > a) = F(a).
Next · Discrete and continuousJumps in a CDF
02
Discrete and continuous

Jumps in a CDF

Jump in the CDFIf FF rises from F1F_1 to F2F_2 at x1x_1, then the jump gives the probability of exactly that value:
P(X=x1)=F2−F1P(X = x_1) = F_2 - F_1
  • In a discrete variable, the CDF is a staircase; each step sits at a value XX can take.
  • The height of the step is the probability of exactly that value.

2.1Worked question: reading probabilities off a staircase

A random variable has the CDF below. Find P(X=0)P(X = 0), P(X=1)P(X = 1) and P(X=2)P(X = 2).

FX(x)={0x<0130≤x<1121≤x<21x≥2F_X(x) = \begin{cases} 0 & x < 0 \\ \tfrac{1}{3} & 0 \le x < 1 \\ \tfrac{1}{2} & 1 \le x < 2 \\ 1 & x \ge 2 \end{cases}
ValueF just beforeF at the valueP(X = x) = F₂ − F₁
001/31/3 − 0 = 1/3
11/31/21/2 − 1/3 = 3/6 − 2/6 = 1/6
21/211 − 1/2 = 1/2
-1012300.250.50.751jump 1/3jump 1/6jump 1/2xy
Figure 3. The staircase CDF: the heights of the three jumps are P(X = 0) = 1/3, P(X = 1) = 1/6 and P(X = 2) = 1/2
Check

The three probabilities add up: 13+16+12=2+1+36=1\frac{1}{3} + \frac{1}{6} + \frac{1}{2} = \frac{2 + 1 + 3}{6} = 1. The jumps of a CDF always add up to 1 (or to the total jump that is left).

2.2Going deeper

  1. Closed dot at the top of the step. The CDF includes the value itself (≤\le), so at x=0x = 0 it is already 13\frac{1}{3}.
  2. From CDF to PMF. Every jump height is a PMF value, so the staircase carries the whole PMF: 0 →\to 13\frac{1}{3}, 1 →\to 16\frac{1}{6}, 2 →\to 12\frac{1}{2}.
  3. A mixed variable has both: jumps at some values and a smooth rise between them (the right picture of Figure 1).
Exam tips
  • Compute each jump as (value after) − (value before).
Common mistakes
  • Reading the height of the CDF (12\frac{1}{2}) as the probability instead of the jump (16\frac{1}{6}).
Next · Continuous variablesThe CDF of a Continuous Variable
03
Continuous variables

The CDF of a Continuous Variable

Continuous CDFA continuous random variable has a CDF with no jumps, so any exact single value has probability zero and only intervals matter.
F continuous at x0  ⇒  P(X=x0)=0F \text{ continuous at } x_0 \;\Rightarrow\; P(X = x_0) = 0

So end points can be included or left out:

P(a≤X≤b)=P(a<X<b)=P(a≤X<b)=P(a<X≤b)P(a \le X \le b) = P(a < X < b) = P(a \le X < b) = P(a < X \le b)

3.1Worked question: finding the exponent k

A random variable has the CDF below. Find P(1<X<2)P(1 < X < 2).

FX(x)={0x<1(x−1)k81≤x<31x≥3F_X(x) = \begin{cases} 0 & x < 1 \\ \dfrac{(x-1)^k}{8} & 1 \le x < 3 \\ 1 & x \ge 3 \end{cases}
  1. Find k from the join at x = 3. The CDF cannot jump, so the middle piece must reach 1 at x=3x = 3: (3−1)k8=1\frac{(3-1)^k}{8} = 1, so 2k8=1\frac{2^k}{8} = 1 and 2k=82^k = 8, hence k=3k = 3.
  2. Interval probability. P(1<X<2)=F(2)−F(1)=(2−1)38−0=18P(1 < X < 2) = F(2) - F(1) = \frac{(2-1)^3}{8} - 0 = \frac{1}{8}.
-0.500.511.522.533.5400.250.50.751F(1) = 0F(2) = 1/8F(3) = 1xy
Figure 4. The continuous CDF with k = 3: no jumps, and P(1 < X < 2) = F(2) − F(1) = 1/8

3.2Going deeper

  1. Why a single value has probability 0. The probability of an interval of width ww shrinks to 0 as w→0w \to 0, so the single point x0x_0 gets F(x0)−F(x0)=0F(x_0) - F(x_0) = 0.
  2. Probability 0 is not impossible. The event X=x0X = x_0 can be a possible outcome yet have probability 0 (extra remark).
  3. Contrast with discrete. For a discrete variable P(1<X<2)P(1 < X < 2) and P(1≤X≤2)P(1 \le X \le 2) can differ; for a continuous one they never do.
Exam tips
  • To find an unknown constant, use that the CDF reaches 1 at the right end.
Common mistakes
  • Treating P(X=2)P(X = 2) as non-zero for a continuous variable.
Next · Continuous variablesDensity Functions
04
Continuous variables

Density Functions

For a continuous random variable P(X=x)P(X = x) is 0, so we use a density function f(x)f(x). Probability is the area under ff over an interval, and a high density means XX takes values around there more often.

CDF: accumulated density
FX(x0)=∫−∞x0fX(x) dxF_X(x_0) = \int_{-\infty}^{x_0} f_X(x)\, dx
PDF: slope of the CDF
fX(x)=FX′(x)f_X(x) = F_X'(x)

The PDF is easier for probability calculations and shows the shape of the distribution.

4.1A valid PDF and finding k

Never negative
  • f(x)≥0f(x) \ge 0
Total area 1
  • ∫−∞∞f(x) dx=1\displaystyle\int_{-\infty}^{\infty} f(x)\, dx = 1

The density must never be negative and must enclose total area 1. Using this we find kk.

-0.500.511.522.500.250.50.751√3area = 0.75xy
Figure 5. The density f(x) = x/2 on [0, 2]. Probability is area: the shaded area up to √3 is 0.75, and the whole area under the curve is 1

Worked question: find k

A random variable has PDF fX(x)=ke−xf_X(x) = ke^{-x} for x≥0x \ge 0 and 0 otherwise. Find kk.

∫0∞ke−x dx=1  ⇒  k[e−x−1]0∞=1  ⇒  k[0−(1−1)]=1  ⇒  k⋅1=1\int_0^{\infty} ke^{-x}\, dx = 1 \;\Rightarrow\; k\left[\frac{e^{-x}}{-1}\right]_0^{\infty} = 1 \;\Rightarrow\; k\left[0 - \left(\frac{1}{-1}\right)\right] = 1 \;\Rightarrow\; k \cdot 1 = 1
Answer

k=1k = 1

The upper limit gives e−∞=0e^{-\infty} = 0, and the lower limit gives e0−1=−1\frac{e^{0}}{-1} = -1, so the bracket is 0−(−1)=10 - (-1) = 1.

4.2Going deeper

  1. The PDF can be bigger than 1. It is a density, not a probability; only areas are probabilities. A PDF equal to 5 on a very narrow interval is fine (extra remark).
  2. CDF and PDF are two views of one thing. The CDF accumulates the PDF; the PDF is the slope of the CDF. For F(x)=1−e−0.5xF(x) = 1 - e^{-0.5x} the PDF is f(x)=0.5e−0.5xf(x) = 0.5e^{-0.5x}.
  3. Always integrate over where the PDF is non-zero. Here that is x≥0x \ge 0; outside it f=0f = 0.
Exam tips
  • To find a constant: set the total area to 1 and solve.
  • Check that the final PDF is non-negative.
Common mistakes
  • Integrating from −∞-\infty when the PDF is 0 there (it adds nothing, but write the right limits).
  • Calling a PDF value a probability.
Next · Continuous variablesProbability from a PDF and Percentiles
05
Continuous variables

Probability from a PDF and Percentiles

Definition: probability from a PDFProbability from a PDF is the area under it between the two limits:
∫abf(x) dx=P(a≤X≤b)=F(b)−F(a)\int_a^b f(x)\, dx = P(a \le X \le b) = F(b) - F(a)

5.1Worked question: how much petrol to stock

At a petrol station the daily petrol demand XX (in thousands of litres) has PDF fX(x)=k(1−x)4f_X(x) = k(1 - x)^4 for 0≤x≤10 \le x \le 1, and 0 otherwise. What should be the minimum supply ss (in thousands of litres) so that the probability of the petrol running out on any given day is only 1%? (a) 0.4321 (b) 0.3981 (c) 0.6019 (d) 0.9903

  1. Find k. ∫01k(1−x)4 dx=k[−(1−x)55]01=k5=1\int_0^1 k(1-x)^4\, dx = k\left[\frac{-(1-x)^5}{5}\right]_0^1 = \frac{k}{5} = 1, so k=5k = 5 and f(x)=5(1−x)4f(x) = 5(1-x)^4.
  2. Running out means demand above supply. We need P(X>s)=0.01P(X > s) = 0.01, that is ∫s15(1−x)4 dx=0.01\int_s^1 5(1-x)^4\, dx = 0.01.
  3. Integrate. 5[(1−x)5−5]s1=(1−s)55\left[\frac{(1-x)^5}{-5}\right]_s^1 = (1-s)^5, so (1−s)5=0.01(1-s)^5 = 0.01.
  4. Solve. 1−s=(0.01)1/5≈0.39811 - s = (0.01)^{1/5} \approx 0.3981, so s=1−(0.01)1/5≈0.6019s = 1 - (0.01)^{1/5} \approx 0.6019.
Answer

The minimum supply is about 0.6019 thousand litres: option (c).

-0.200.20.40.60.811.2012345s = 0.6019tail area = 0.01xy
Figure 6. The petrol demand density 5(1 − x)⁴. The tiny shaded tail beyond s = 0.6019 has area 0.01: that is the chance of running out

5.2Percentiles

Definition: percentileThe value kk with P(X≤k)=pP(X \le k) = p is the 100p100p-th percentile.
P(X≤k)=pP(X \le k) = p

Worked question: the 75th percentile

A random variable has PDF fX(x)=kxf_X(x) = kx for 0≤x<20 \le x < 2, and 0 otherwise. Find the 75th percentile of XX. (Hint: the value kk such that P(X≤k)=0.75P(X \le k) = 0.75.) Note that the letter kk is used twice: first as the constant in the PDF, then as the percentile.

  1. Find the constant. ∫02kx dx=2k=1\int_0^2 kx\, dx = 2k = 1, so the constant is 12\frac{1}{2} and f(x)=x2f(x) = \frac{x}{2}.
  2. Set up the percentile. P(X≤k)=∫0kx2 dx=[x24]0k=k24=0.75P(X \le k) = \int_0^k \frac{x}{2}\, dx = \left[\frac{x^2}{4}\right]_0^k = \frac{k^2}{4} = 0.75.
  3. Solve. k2=3k^2 = 3, so k=3≈1.732k = \sqrt{3} \approx 1.732 (the positive root, since 0≤X<20 \le X < 2).
Answer

The 75th percentile is 3≈1.732\sqrt{3} \approx 1.732; the shaded area in Figure 5 is exactly 0.75.

5.3Going deeper

  1. Tail probabilities are what safety margins ask for. “Running out only 1% of days” means choosing ss so the upper tail has area 0.01, i.e. ss is the 99th percentile of the demand.
  2. The median is the 50th percentile. For f(x)=x2f(x) = \frac{x}{2} it solves k24=0.5\frac{k^2}{4} = 0.5, so k=2k = \sqrt{2} (extra remark).
  3. Check the numbers. (0.3981)5≈0.0100(0.3981)^5 \approx 0.0100, and (3)24=0.75\frac{(\sqrt{3})^2}{4} = 0.75.
Exam tips
  • For a percentile, integrate the PDF from its left end up to kk and set it equal to pp.
Common mistakes
  • Mixing up the two uses of the letter kk.
  • Taking the negative square root.
Next · Continuous variablesConditional Probability, Uniform and Exponential
06
Continuous variables

Conditional Probability, Uniform and Exponential

Definition: conditional probabilityConditional probability. BB is the given condition; find the probability of AA after the occurrence of BB:
P(A∣B)=P(A∩B)P(B)P(A \mid B) = \frac{P(A \cap B)}{P(B)}

For example P(X<s∣X>t)P(X < s \mid X > t) with t<st < s becomes P(t<X<s)P(X>t)\dfrac{P(t < X < s)}{P(X > t)}.

6.1Practice on conditional probability

Question 1

A random variable has PDF fX(x)=5x4f_X(x) = 5x^4 for 0<x≤10 < x \le 1, and 0 otherwise. Find P(X≤814∣X>114)P\left(X \le \frac{8}{14} \mid X > \frac{1}{14}\right).

P(114<X≤814)P(X>114)=∫1/148/145x4 dx∫1/1415x4 dx=(814)5−(114)51−(114)5=85−1145−1=32767537823≈0.0609\frac{P\left(\frac{1}{14} < X \le \frac{8}{14}\right)}{P\left(X > \frac{1}{14}\right)} = \frac{\int_{1/14}^{8/14} 5x^4\, dx}{\int_{1/14}^{1} 5x^4\, dx} = \frac{\left(\frac{8}{14}\right)^5 - \left(\frac{1}{14}\right)^5}{1 - \left(\frac{1}{14}\right)^5} = \frac{8^5 - 1}{14^5 - 1} = \frac{32767}{537823} \approx 0.0609

Question 2

Same PDF. Find P(X≤67∣X>17)P\left(X \le \frac{6}{7} \mid X > \frac{1}{7}\right).

∫1/76/75x4 dx∫1/715x4 dx=(67)5−(17)51−(17)5=65−175−1=777516806≈0.4626\frac{\int_{1/7}^{6/7} 5x^4\, dx}{\int_{1/7}^{1} 5x^4\, dx} = \frac{\left(\frac{6}{7}\right)^5 - \left(\frac{1}{7}\right)^5}{1 - \left(\frac{1}{7}\right)^5} = \frac{6^5 - 1}{7^5 - 1} = \frac{7775}{16806} \approx 0.4626
The handwritten notes stop at the set-upThe notes write the two integrals and stop. The final numbers 0.0609 and 0.4626 are worked out here from ∫5x4 dx=x5\int 5x^4\, dx = x^5.

6.2The uniform and exponential distributions

Uniform: X ~ U[a, b]
f(x)=1b−a,F(x)=x−ab−af(x) = \frac{1}{b - a}, \qquad F(x) = \frac{x - a}{b - a}

Equally likely everywhere on [a,b][a, b].

Exponential: X ~ Exp(λ)
f(x)=λe−λx,x≥0f(x) = \lambda e^{-\lambda x}, \quad x \ge 0

Waiting times; most mass near 0.

Question 3: package delivery (Statistics 2 Quiz 1, 13 Jul 2025)

A package delivery time TT (in hours) is uniformly distributed over the interval [a,b][a, b]. The probability that the delivery takes less than 5 hours is equal to the probability that it takes more than 11 hours. If the value of bb is 14, find P(5<T<11∣T>7)P(5 < T < 11 \mid T > 7).

  1. Find a. P(T<5)=5−ab−aP(T < 5) = \frac{5 - a}{b - a} and P(T>11)=b−11b−aP(T > 11) = \frac{b - 11}{b - a}. Equal, so 5−a=b−115 - a = b - 11, hence a+b=16a + b = 16 and, with b=14b = 14, a=2a = 2.
  2. Conditional probability. P(5<T<11∣T>7)=P(7<T<11)P(T>7)P(5 < T < 11 \mid T > 7) = \frac{P(7 < T < 11)}{P(T > 7)}, because inside T>7T > 7 the event 5<T<115 < T < 11 means 7<T<117 < T < 11.
  3. Lengths. The numerator has length 11−7=411 - 7 = 4 and the denominator 14−7=714 - 7 = 7 (the common width b−a=12b - a = 12 cancels).
Answer

47\dfrac{4}{7}

02468101214160.000.040.080.12P(7 < T < 11)f = 1/12xy
Figure 7. T is uniform on [2, 14] with density 1/12. The shaded area P(7 < T < 11) = 4/12, and P(T > 7) = 7/12, so the ratio is 4/7

Question 4: finding a (Statistics 2 Quiz 1, 23 Feb 2025)

The PDF of a random variable XX is fX(x)=ae−3xf_X(x) = ae^{-3x} for x≥0x \ge 0, and 0 otherwise. Find the value of aa.

∫0∞ae−3x dx=a[e−3x−3]0∞=a(0−1−3)=a3=1  ⇒  a=3\int_0^{\infty} ae^{-3x}\, dx = a\left[\frac{e^{-3x}}{-3}\right]_0^{\infty} = a\left(0 - \frac{1}{-3}\right) = \frac{a}{3} = 1 \;\Rightarrow\; a = 3

6.3Going deeper

  1. Conditioning shrinks the sample space. Given T>7T > 7, only [7,14][7, 14] is left, of length 7; the uniform density on it is 17\frac{1}{7}, and the answer 47\frac{4}{7} is the length 4 over 7.
  2. The exponent rule. ∫0∞ce−λx dx=cλ\int_0^{\infty} ce^{-\lambda x}\, dx = \frac{c}{\lambda}; setting it to 1 gives c=λc = \lambda, which is why the exponential density is λe−λx\lambda e^{-\lambda x}. In Question 4, λ=3\lambda = 3 so a=3a = 3.
  3. Uniform probabilities are length ratios. P(c<T<d)=d−cb−aP(c < T < d) = \frac{d - c}{b - a} for a≤c<d≤ba \le c < d \le b (extra remark).
Exam tips
  • For a conditional probability, first rewrite the numerator as one interval.
Common mistakes
  • Dividing by b−ab - a again after the condition (the new width is b−7b - 7).
Next · ExpectationsExpectations, Mean and Variance
07
Expectations

Expectations, Mean and Variance

7.1Expected value of a function, mean and variance

Expected value of a function
E[g(X)]=∫−∞∞g(x) fX(x) dxE[g(X)] = \int_{-\infty}^{\infty} g(x)\, f_X(x)\, dx
Mean
E[X]=μ=∫−∞∞x fX(x) dxE[X] = \mu = \int_{-\infty}^{\infty} x\, f_X(x)\, dx
Variance
Var(X)=E[X2]−(E[X])2\text{Var}(X) = E[X^2] - (E[X])^2

Question 5: variance of a continuous variable (Statistics 2 Quiz 1, 13 Jul 2025)

Let XX be a continuous random variable with PDF fX(x)=x2f_X(x) = \frac{x}{2} for 0≤x≤20 \le x \le 2, and 0 otherwise. Calculate Var(X)\text{Var}(X).

  1. Mean. E[X]=∫02x⋅x2 dx=12[x33]02=12⋅83=43E[X] = \int_0^2 x \cdot \frac{x}{2}\, dx = \frac{1}{2}\left[\frac{x^3}{3}\right]_0^2 = \frac{1}{2} \cdot \frac{8}{3} = \frac{4}{3}.
  2. Second moment. E[X2]=∫02x2⋅x2 dx=12[x44]02=12⋅164=2E[X^2] = \int_0^2 x^2 \cdot \frac{x}{2}\, dx = \frac{1}{2}\left[\frac{x^4}{4}\right]_0^2 = \frac{1}{2} \cdot \frac{16}{4} = 2.
  3. Variance. Var(X)=E[X2]−(E[X])2=2−(43)2=2−169=29≈0.222\text{Var}(X) = E[X^2] - (E[X])^2 = 2 - \left(\frac{4}{3}\right)^2 = 2 - \frac{16}{9} = \frac{2}{9} \approx 0.222.

Question 6: a linear change

For the same XX, define Y=72X+5Y = 72X + 5. Find Var(Y)\text{Var}(Y).

Var(Y)=Var(72X+5)=722 Var(X)=5184×29=1152\text{Var}(Y) = \text{Var}(72X + 5) = 72^2\, \text{Var}(X) = 5184 \times \frac{2}{9} = 1152
A discrepancy in the handwritten notesIn the handwritten page the last step reads 722×0.472^2 \times 0.4, and a scribbled “1.5” and “0.45” sit next to the variance. The working on the same page gives E[X]=43E[X] = \frac{4}{3} and E[X2]=2E[X^2] = 2, which lead to Var(X)=29\text{Var}(X) = \frac{2}{9}, not 0.4. These notes use 29\frac{2}{9}, so Var(Y)=1152\text{Var}(Y) = 1152.

7.2Uniform [a, b]

Mean
E[X]=a+b2E[X] = \frac{a + b}{2}
Variance
Var(X)=(b−a)212\text{Var}(X) = \frac{(b - a)^2}{12}

Question 7: the value of a + b (Statistics 2 Quiz 1, 13 Jul 2025)

A package delivery time TT (in hours) is uniformly distributed over [a,b][a, b]. The probability that the delivery takes less than 5 hours is equal to the probability that it takes more than 11 hours. Find a+ba + b.

P(T<5)=5−ab−a,P(T>11)=b−11b−a  ⇒  5−a=b−11  ⇒  a+b=16P(T < 5) = \frac{5 - a}{b - a}, \quad P(T > 11) = \frac{b - 11}{b - a} \;\Rightarrow\; 5 - a = b - 11 \;\Rightarrow\; a + b = 16
Why this works

The two cut-off points 5 and 11 are the same distance from the two ends of [a,b][a, b], so the interval is symmetric about their midpoint: a+b2=5+112=8\frac{a + b}{2} = \frac{5 + 11}{2} = 8, i.e. a+b=16a + b = 16.

7.3Exponential (λ)

Mean
E[X]=1λE[X] = \frac{1}{\lambda}
Variance
Var(X)=1λ2\text{Var}(X) = \frac{1}{\lambda^2}

Question 8: Jadeja batting (Statistics 2 Quiz 1, 5 Jun 2022)

During an IPL cricket match, the amount of time (in minutes) Jadeja bats follows the exponential distribution with an expected time of 50 minutes. What is the probability that Jadeja will bat for more than 40 minutes?

  1. Find λ. E[X]=1λ=50E[X] = \frac{1}{\lambda} = 50, so λ=150\lambda = \frac{1}{50} and f(x)=150e−x/50f(x) = \frac{1}{50}e^{-x/50}.
  2. Tail probability. P(X>40)=∫40∞150e−x/50 dx=[−e−x/50]40∞=e−40/50P(X > 40) = \int_{40}^{\infty} \frac{1}{50}e^{-x/50}\, dx = \left[-e^{-x/50}\right]_{40}^{\infty} = e^{-40/50}.
Answer

e−40/50=e−0.8≈0.449e^{-40/50} = e^{-0.8} \approx 0.449

Question 9: the service center (Statistics 2 Quiz 1, 13 Jul 2025)

The time (in minutes) a customer spends inside a service center follows an exponential distribution with an average of 10 minutes. What is the probability that a customer has to wait at least 12 more minutes in the center, given that he has already spent 10 minutes in the center?

  1. Set up. The notes write P(X>12∣X>10)P(X > 12 \mid X > 10), reading “12 more” loosely as the interval from the start; the question asks for 12 more minutes after 10, which is P(X>22∣X>10)P(X > 22 \mid X > 10).
  2. Rate. λ=110\lambda = \frac{1}{10}, so P(X>t)=e−t/10P(X > t) = e^{-t/10}.
  3. Conditional probability. P(X>22∣X>10)=P(X>22)P(X>10)=e−2.2e−1=e−1.2≈0.301P(X > 22 \mid X > 10) = \frac{P(X > 22)}{P(X > 10)} = \frac{e^{-2.2}}{e^{-1}} = e^{-1.2} \approx 0.301. For comparison the notes' set-up P(X>12∣X>10)=e−0.2≈0.819P(X > 12 \mid X > 10) = e^{-0.2} \approx 0.819.
The handwritten notes stop at the set-upThe page writes P(x>12∣x>10)P(x > 12 \mid x > 10) and leaves the working blank, so both the set-up and the final numbers here are worked out from the formulas. The exponential distribution is memoryless (an extra remark): P(X>s+t∣X>s)=P(X>t)P(X > s + t \mid X > s) = P(X > t), so already waiting 10 minutes changes nothing: the chance of 12 more minutes is P(X>12)=e−1.2≈0.301P(X > 12) = e^{-1.2} \approx 0.301. If the question meant 12 minutes in total, the answer would be e−0.2≈0.819e^{-0.2} \approx 0.819.

7.4Normal (μ, σ²)

Mean
E[X]=μE[X] = \mu
Variance
Var(X)=σ2\text{Var}(X) = \sigma^2

The notes end here with the mean and variance of the normal distribution, written in terms of its two parameters.

7.5Going deeper

  1. Same formulas as discrete, with integrals. The sum ∑x P(X=x)\sum x\,P(X = x) of Week 3 becomes ∫x f(x) dx\int x\, f(x)\, dx.
  2. Linear change of variance. Var(aX+b)=a2 Var(X)\text{Var}(aX + b) = a^2\,\text{Var}(X): the shift bb does nothing, the scale aa is squared (as in Statistics 1, Week 3).
  3. Check against the formulas. For f(x)=x2f(x) = \frac{x}{2} on [0,2][0, 2] the mean 43\frac{4}{3} lies to the right of the middle 1, as the density is larger on the right.
  4. Uniform check. For U[2,14]U[2, 14]: mean 2+142=8\frac{2 + 14}{2} = 8 (the midpoint) and variance 12212=12\frac{12^2}{12} = 12.
Exam tips
  • Compute E[X]E[X] and E[X2]E[X^2] separately, then subtract.
  • For exponential problems, find λ\lambda from the mean first.
Common mistakes
  • Writing Var(72X+5)=72 Var(X)+5\text{Var}(72X + 5) = 72\,\text{Var}(X) + 5.
  • Using the mean as λ\lambda instead of 1λ\frac{1}{\lambda}.
Next · SummaryWeek 4 Summary Sheet
08
Summary

Week 4 Summary Sheet

Everything in Week 4 on one sheet, for a last-minute revision.

CDF and PDF

CDF
F(x)=P(X≤x),P(a<X≤b)=F(b)−F(a),P(X>a)=1−F(a)F(x) = P(X \le x),\quad P(a < X \le b) = F(b) - F(a),\quad P(X > a) = 1 - F(a)
Discrete jump
P(X=x1)=F2−F1P(X = x_1) = F_2 - F_1
PDF
F(x0)=∫−∞x0f,f=F′,f≥0,∫f=1F(x_0) = \int_{-\infty}^{x_0} f,\quad f = F',\quad f \ge 0,\quad \int f = 1
Interval and percentile
∫abf=F(b)−F(a),P(X≤k)=p\int_a^b f = F(b) - F(a),\quad P(X \le k) = p

Named distributions

Distributionf(x)F(x)E[X]Var(X)
Uniform [a, b]1b−a\frac{1}{b-a}x−ab−a\frac{x-a}{b-a}a+b2\frac{a+b}{2}(b−a)212\frac{(b-a)^2}{12}
Exponential (λ)λe−λx, x≥0\lambda e^{-\lambda x},\ x \ge 01−e−λx1 - e^{-\lambda x}1λ\frac{1}{\lambda}1λ2\frac{1}{\lambda^2}
Normal (μ, σ²)--μ\muσ2\sigma^2

Rules of thumb

SituationWhat to do
Staircase CDFjump height = probability of that value
Continuous variableP(X=x)=0P(X = x) = 0; end points do not matter
Unknown constant in a PDFtotal area = 1
Unknown constant in a CDFpieces must join and reach 1
Conditional probabilityP(A∩B)P(B)\frac{P(A \cap B)}{P(B)}: rewrite the numerator as one interval
Variance of aX+baX + ba2 Var(X)a^2\,\text{Var}(X)

Values computed in the notes

QuestionAnswer
P(X>10)P(X > 10), F=1−e−0.5xF = 1 - e^{-0.5x}e−5≈0.0067e^{-5} \approx 0.0067
piecewise CDF: kk, P(1≤X≤5)P(1 \le X \le 5)k=12k = \frac{1}{2}, 34\frac{3}{4}
staircase: P(X=0,1,2)P(X = 0, 1, 2)13, 16, 12\frac{1}{3},\ \frac{1}{6},\ \frac{1}{2}
F=(x−1)k8F = \frac{(x-1)^k}{8}: kk, P(1<X<2)P(1 < X < 2)k=3k = 3, 18\frac{1}{8}
f=ke−xf = ke^{-x}k=1k = 1
petrol supply for 1% risk1−0.011/5≈0.60191 - 0.01^{1/5} \approx 0.6019
75th percentile of x2\frac{x}{2} on [0, 2]3\sqrt{3}
f=5x4f = 5x^4: two conditional probabilities≈0.0609, 0.4626\approx 0.0609,\ 0.4626
uniform delivery: P(5<T<11∣T>7)P(5 < T < 11 \mid T > 7), a+ba + b47\frac{4}{7}, 1616
f=ae−3xf = ae^{-3x}a=3a = 3
Var(X)\text{Var}(X), Var(72X+5)\text{Var}(72X + 5) for f=x2f = \frac{x}{2}29\frac{2}{9}, 11521152
Jadeja: P(X>40)P(X > 40), mean 50e−0.8≈0.449e^{-0.8} \approx 0.449
service center, 12 more minutese−1.2≈0.301e^{-1.2} \approx 0.301
Revision overview
Discrete or continuousDiscrete: countable values, PMF, staircase CDF
Continuous: intervals, smooth CDF
CDFF(x) = P(X ≤ x)
P(a < X ≤ b) = F(b) − F(a)
never decreases, from 0 to 1
JumpsP(X = x₁) = F₂ − F₁
continuous: P(X = x₀) = 0
Continuous variablesStatistics for Data Science 2 · Week 4
PDFf = F′, f ≥ 0, ∫f = 1
probability = area under f
percentile: P(X ≤ k) = p
Conditional probabilityP(A | B) = P(A ∩ B) / P(B)
Uniform [a, b], Exp(λ)
ExpectationsE[g(X)] = ∫ g f
Var = E[X²] − (E[X])²
U: (a+b)/2, (b−a)²/12 · Exp: 1/λ, 1/λ²
Revision: the whole of Week 4 on one map
Back to top