Quiz 2

Continuous Random Variables — PDF, CDF, and Properties

1975 words
10 min read
Python Week 1: the first filter for runtime behavior
Visual companion
Python
Type and operator map

Python Week 1: the first filter for runtime behavior

View
Revision summary

What this note is really saying

Short form

# Continuous Random Variables — PDF, CDF, and Properties ## 🎯 Learning Objectives After completing this topic, you will be able to: - Distinguish **continuous** from **discrete** random variables - Understand **probability density functions (PDF)** and why $P(X = a) = 0$ - Compute probabilities as **areas under the...

Continuous Random Variables — PDF, CDF, and Properties

🎯 Learning Objectives

After completing this topic, you will be able to:
  • Distinguish continuous from discrete random variables
  • Understand probability density functions (PDF) and why P(X=a)=0P(X = a) = 0
  • Compute probabilities as areas under the PDF using integration
  • Find and interpret the CDF for continuous RVs
  • Compute expected value and variance for continuous RVs
  • Find the median and percentiles of a continuous distribution

📋 Prerequisites

  • Discrete Random Variables (15-discrete-random-variables) — PMF, expected value, variance
  • Basic integration from BSMA1001-maths-1
  • Understanding of area under a curve

📖 Core Content

17.1 Intuition: From Counting to Measuring

With discrete random variables, we count specific outcomes (number of heads). With continuous random variables, we measure quantities on a continuous scale (height, time, temperature). The key difference: For discrete RVs, P(X=x)P(X = x) can be > 0. For continuous RVs, P(X=x)=0P(X = x) = 0 for any specific value. Why? There are infinitely many possible values. The probability of hitting exactly 170.000000... cm is vanishingly small. Instead, we talk about ranges: "What's the probability height is between 170 and 175 cm?"
Everyday analogy: The chance you arrive at exactly 3:00:00.000... PM is essentially zero. But the chance you arrive between 2:55 and 3:05 PM is meaningful. 🔑 Key Insight: For continuous RVs, probability is represented by area, not height. The density function gives the "concentration" of probability.

17.2 Probability Density Function (PDF)

17.2.1 Definition

A probability density function f(x)f(x) describes the relative likelihood of a continuous random variable taking on a value near x. Properties:
  1. f(x)0f(x) \geq 0 for all x (density can't be negative)
  2. f(x)dx=1\int_{-\infty}^{\infty} f(x) \, dx = 1 (total area under the PDF = 1)
  3. P(aXb)=abf(x)dxP(a \leq X \leq b) = \int_a^b f(x) \, dx (probability = area under curve)

17.2.2 Important: PDF ≠ Probability

The PDF f(x)f(x) is not a probability. Probabilities for continuous RVs are always areas (integrals). The value f(a)f(a) is a density, not a probability.

17.3 Cumulative Distribution Function (CDF)

17.3.1 Definition

F(x)=P(Xx)=xf(t)dtF(x) = P(X \leq x) = \int_{-\infty}^x f(t) \, dt
Properties:
  1. F(x)=f(x)F'(x) = f(x) (the derivative of the CDF is the PDF)
  2. limxF(x)=0\lim_{x \to -\infty} F(x) = 0
  3. limx+F(x)=1\lim_{x \to +\infty} F(x) = 1
  4. P(a<X<b)=F(b)F(a)P(a < X < b) = F(b) - F(a)

17.4 Expected Value and Variance

Expected Value

E(X)=μ=xf(x)dxE(X) = \mu = \int_{-\infty}^{\infty} x \cdot f(x) \, dx

Expected Value of a Function

E(g(X))=g(x)f(x)dxE(g(X)) = \int_{-\infty}^{\infty} g(x) \cdot f(x) \, dx

Variance

Var(X)=σ2=(xμ)2f(x)dx=E(X2)[E(X)]2Var(X) = \sigma^2 = \int_{-\infty}^{\infty} (x - \mu)^2 f(x) \, dx = E(X^2) - [E(X)]^2

Standard Deviation

σX=Var(X)\sigma_X = \sqrt{Var(X)}

17.5 Worked Examples

Example 1: Validating a PDF (Easy)

Scenario: f(x)=kxf(x) = kx for 0x20 \leq x \leq 2, 0 otherwise. Find k so this is a valid PDF. Solution: Condition: f(x)dx=1\int_{-\infty}^{\infty} f(x) dx = 1
02kxdx=k[x22]02=k(2)=1\int_0^2 kx \, dx = k \left[\frac{x^2}{2}\right]_0^2 = k(2) = 1
So k=1/2k = 1/2. The valid PDF is f(x)=x/2f(x) = x/2 for 0x20 \leq x \leq 2.

Example 2: Computing a Probability (Medium)

Scenario: XX has PDF
f(x)={34(1x2),1x10,otherwisef(x) = \begin{cases} \frac{3}{4}(1 - x^2), & -1 \leq x \leq 1 \\ 0, & \text{otherwise} \end{cases}
Find P(0X0.5)P(0 \leq X \leq 0.5). Solution:
P(0X0.5)=00.534(1x2)dxP(0 \leq X \leq 0.5) = \int_0^{0.5} \frac{3}{4}(1 - x^2) \, dx =34[xx33]00.5=34[(0.5)(0.5)330]= \frac{3}{4} \left[x - \frac{x^3}{3}\right]_0^{0.5} = \frac{3}{4} \left[(0.5) - \frac{(0.5)^3}{3} - 0\right] =34[0.50.1253]=34[0.50.0417]=34×0.45830.344= \frac{3}{4} \left[0.5 - \frac{0.125}{3}\right] = \frac{3}{4} [0.5 - 0.0417] = \frac{3}{4} \times 0.4583 \approx 0.344

Example 3: Expected Value and Variance (Harder)

Scenario: f(x)=32x2f(x) = \frac{3}{2}x^2 for 1x1-1 \leq x \leq 1, 0 otherwise. Find E(X)E(X), E(X2)E(X^2), and Var(X)Var(X). Solution:
E(X)=11x32x2dx=3211x3dx=32[x44]11=32(1414)=0E(X) = \int_{-1}^1 x \cdot \frac{3}{2}x^2 \, dx = \frac{3}{2} \int_{-1}^1 x^3 \, dx = \frac{3}{2} \left[\frac{x^4}{4}\right]_{-1}^1 = \frac{3}{2} \left(\frac{1}{4} - \frac{1}{4}\right) = 0 E(X2)=11x232x2dx=3211x4dx=32[x55]11=32(15+15)=32×25=35E(X^2) = \int_{-1}^1 x^2 \cdot \frac{3}{2}x^2 \, dx = \frac{3}{2} \int_{-1}^1 x^4 \, dx = \frac{3}{2} \left[\frac{x^5}{5}\right]_{-1}^1 = \frac{3}{2} \left(\frac{1}{5} + \frac{1}{5}\right) = \frac{3}{2} \times \frac{2}{5} = \frac{3}{5} Var(X)=E(X2)[E(X)]2=350=0.6Var(X) = E(X^2) - [E(X)]^2 = \frac{3}{5} - 0 = 0.6

17.6 Percentiles and Median

The p-th percentile is the value xpx_p such that F(xp)=p/100F(x_p) = p/100. The median is the 50th percentile: F(median)=0.5F(\text{median}) = 0.5. Example: For f(x)=x/2f(x) = x/2 on [0,2][0, 2], find the median.
F(x)=0xt2dt=[t24]0x=x24F(x) = \int_0^x \frac{t}{2} \, dt = \left[\frac{t^2}{4}\right]_0^x = \frac{x^2}{4}
Set F(x)=0.5F(x) = 0.5: x24=0.5\frac{x^2}{4} = 0.5, x2=2x^2 = 2, x=21.414x = \sqrt{2} \approx 1.414 The median is approximately 1.414.

17.7 Discrete vs. Continuous — Summary Table

PropertyDiscreteContinuous
Probability at a pointP(X=x)0P(X=x) \geq 0P(X=x)=0P(X=x) = 0
DistributionPMF p(x)p(x)PDF f(x)f(x)
CDFF(x)=txp(t)F(x) = \sum_{t \leq x} p(t)F(x)=xf(t)dtF(x) = \int_{-\infty}^x f(t) dt
P(aXb)P(a \leq X \leq b)x=abp(x)\sum_{x=a}^b p(x)abf(x)dx\int_a^b f(x) dx
Expected valuexp(x)\sum x \cdot p(x)xf(x)dx\int x \cdot f(x) dx
ValuesCountableUncountable (interval)

17.8 Why This Matters

Continuous random variables model:
  • Physical measurements (height, weight, time)
  • Financial variables (stock returns, interest rates)
  • Natural phenomena (temperature, rainfall)
  • They lead directly to Weeks 12-13 distributions (Uniform, Exponential, Normal)

📐 Key Formulas / Concepts

ConceptFormulaNotes
PDF propertiesf(x)0f(x) \geq 0 , f(x)dx=1\int f(x) dx = 1Density, not probability
Probability via PDFP(aXb)=abf(x)dxP(a \leq X \leq b) = \int_a^b f(x) dxArea under curve
CDFF(x)=xf(t)dtF(x) = \int_{-\infty}^x f(t) dtNon-decreasing
PDF from CDFf(x)=F(x)f(x) = F'(x)Derivative
Expected ValueE(X)=xf(x)dxE(X) = \int_{-\infty}^\infty x f(x) dxCenter of mass
VarianceVar(X)=E(X2)[E(X)]2Var(X) = E(X^2) - [E(X)]^2Spread
MedianF(median)=0.5F(\text{median}) = 0.550th percentile

⚠️ Common Pitfalls

Pitfall 1: Thinking f(x)f(x) Is a Probability

The mistake: Saying P(X=1.5)=f(1.5)P(X = 1.5) = f(1.5). Correction: For continuous variables, P(X=a)=0P(X = a) = 0 always. The PDF f(a)f(a) is a density — it can even be >1 (as long as the total area is 1).

Pitfall 2: Forgetting to Check PDF Validity

The mistake: Assuming any non-negative function is a valid PDF. Correction: Always check f(x)dx=1\int f(x) dx = 1. If not, scale it (find the normalization constant).

Pitfall 3: Using Summation Instead of Integration

The mistake: Writing E(X)=xf(x)E(X) = \sum xf(x) for continuous variables. Correction: For continuous, use xf(x)dx\int xf(x) dx. Summation is for discrete.

📝 Practice Questions

Q1: PDF Validation
</strong>
Is f(x)=2xf(x) = 2x for 0x10 \leq x \leq 1 a valid PDF?
<details> <strong>Solution</strong>
f(x)0f(x) \geq 0 ✓ for x[0,1]x \in [0,1]
012xdx=[x2]01=10=1\int_0^1 2x \, dx = [x^2]_0^1 = 1 - 0 = 1
Yes, it's a valid PDF.
</details> > **Q2: Finding a Constant** > > </strong> > > $f(x) = k$ for $0 \leq x \leq 5$. Find k. > > <details> <strong>Solution</strong> > > $\int_0^5 k \, dx = k \times 5 = 1$, so $k = 1/5$. > > This is the **Uniform(0,5)** distribution. </details> > **Q3: Computing Probability** > > </strong> > > $f(x) = 3x^2$ for $0 \leq x \leq 1$. Find $P(0.2 < X < 0.5)$. > > <details> <strong>Solution</strong> > > $P(0.2 < X < 0.5) = \int_{0.2}^{0.5} 3x^2 \, dx = [x^3]_{0.2}^{0.5} = 0.125 - 0.008 = 0.117$ > > $\boxed{0.117}$ </details> > **Q4: Expected Value** > > </strong> > > $f(x) = 2(1-x)$ for $0 \leq x \leq 1$. Find $E(X)$. > > <details> <strong>Solution</strong> > > $E(X) = \int_0^1 x \cdot 2(1-x) \, dx = 2 \int_0^1 (x - x^2) \, dx = 2 \left[\frac{x^2}{2} - \frac{x^3}{3}\right]_0^1$ > > $= 2 \left(\frac{1}{2} - \frac{1}{3}\right) = 2 \times \frac{1}{6} = \frac{1}{3}$ > > $\boxed{E(X) = 1/3}$ </details> > **Q5: CDF from PDF** > > </strong> > > $f(x) = \frac{1}{2}x$ for $0 \leq x \leq 2$. Find $F(x)$ and $P(X > 1)$. > > <details> <strong>Solution</strong> > > **CDF:** $F(x) = \int_0^x \frac{1}{2}t \, dt = \left[\frac{t^2}{4}\right]_0^x = \frac{x^2}{4}$ for $0 \leq x \leq 2$ > > $F(x) = 0$ for $x < 0$, $F(x) = 1$ for $x > 2$ > > **$P(X > 1)$:** $= 1 - P(X \leq 1) = 1 - F(1) = 1 - \frac{1}{4} = \frac{3}{4}$ > > Or directly: $\int_1^2 \frac{1}{2}x \, dx = [\frac{x^2}{4}]_1^2 = \frac{4}{4} - \frac{1}{4} = \frac{3}{4}$ ✓ > > $\boxed{F(x) = x^2/4,\ P(X > 1) = 3/4}$ </details> > **Q6: Variance** > > </strong> > > $f(x) = \frac{3}{2}\sqrt{x}$ for $0 \leq x \leq 1$. Find $Var(X)$. > > <details> <strong>Solution</strong> > > $E(X) = \int_0^1 x \cdot \frac{3}{2}\sqrt{x} \, dx = \frac{3}{2} \int_0^1 x^{3/2} \, dx = \frac{3}{2} \left[\frac{2}{5}x^{5/2}\right]_0^1 = \frac{3}{2} \times \frac{2}{5} = \frac{3}{5}$ > > $E(X^2) = \int_0^1 x^2 \cdot \frac{3}{2}\sqrt{x} \, dx = \frac{3}{2} \int_0^1 x^{5/2} \, dx = \frac{3}{2} \left[\frac{2}{7}x^{7/2}\right]_0^1 = \frac{3}{2} \times \frac{2}{7} = \frac{3}{7}$ > > $Var(X) = \frac{3}{7} - (\frac{3}{5})^2 = \frac{3}{7} - \frac{9}{25} = \frac{75}{175} - \frac{63}{175} = \frac{12}{175}$ > > $\boxed{Var(X) = 12/175}$ </details> > **Q7: Median** > > </strong> > > $f(x) = \frac{1}{2}$ for $2 \leq x \leq 4$. Find the median. > > <details> <strong>Solution</strong> > > CDF: $F(x) = \int_2^x \frac{1}{2} \, dt = \frac{x-2}{2}$ for $2 \leq x \leq 4$ > > Set $F(x) = 0.5$: $\frac{x-2}{2} = 0.5$ > > $x - 2 = 1$, $x = 3$ > > The median is 3. (For a symmetric uniform distribution, median = mean.) > > $\boxed{\text{Median} = 3}$ </details> > **Q8: Application** > > </strong> > > The lifetime of a battery (in hours) has PDF $f(x) = \frac{1}{100}e^{-x/100}$ for $x \geq 0$. > > Find the probability a battery lasts more than 100 hours. > > <details> <strong>Solution</strong> > > $P(X > 100) = \int_{100}^\infty \frac{1}{100} e^{-x/100} \, dx = \left[-e^{-x/100}\right]_{100}^\infty$ > > $= 0 - (-e^{-1}) = e^{-1} \approx 0.368$ > > About 36.8% of batteries last more than 100 hours. This is an **Exponential** distribution. > > $\boxed{P(X > 100) = e^{-1} \approx 0.368}$ </details> > **Q9: Expected Value of Exponential** > > </strong> > > Using the PDF from Q8, find $E(X)$. > > <details> <strong>Solution</strong> > > $E(X) = \int_0^\infty x \cdot \frac{1}{100} e^{-x/100} \, dx$ > > Using integration by parts: $\int x e^{-x/100} dx = -100x e^{-x/100} - 10000 e^{-x/100}$ > > $E(X) = \frac{1}{100} \left[-100x e^{-x/100} - 10000 e^{-x/100}\right]_0^\infty$ > > As $x \to \infty$, $e^{-x/100} \to 0$, so the upper limit = 0. > > At $x = 0$: $0 - 10000(1) = -10000$ > > $E(X) = \frac{1}{100}[0 - (-10000)] = \frac{10000}{100} = 100$ > > The expected lifetime is 100 hours. This matches the parameter of the exponential distribution. > > $\boxed{E(X) = 100}$ </details> > **Q10: PDF from CDF** > > </strong> > > Given > > >F(x)={0,x<0x3,0x11,x>1>> F(x) = \begin{cases} 0, & x < 0 \\ x^3, & 0 \leq x \leq 1 \\ 1, & x > 1 \end{cases} >
Find the PDF f(x)f(x) and P(0.2X0.5)P(0.2 \leq X \leq 0.5).
<details> <strong>Solution</strong>
PDF:
>f(x)=F(x)={3x2,0x10,otherwise>> f(x) = F'(x) = \begin{cases} 3x^2, & 0 \leq x \leq 1 \\ 0, & \text{otherwise} \end{cases} >
P(0.2X0.5)P(0.2 \leq X \leq 0.5): =F(0.5)F(0.2)=(0.5)3(0.2)3=0.1250.008=0.117= F(0.5) - F(0.2) = (0.5)^3 - (0.2)^3 = 0.125 - 0.008 = 0.117
f(x)=3x2, P=0.117\boxed{f(x) = 3x^2,\ P = 0.117}
</details> * * * ## 🔗 Cross-References - **Next topic:** [Expectation](/courses/bsma1002/notes/17-expectation) — deeper dive into expected value properties - **Previous:** [Discrete Random Variables](/notes/01-foundation-bsma1002-stats-1-week09-15-discrete-random-variables) — the discrete analogue - **Week 12 (Distributions):** Uniform, Exponential, Normal — specific continuous distributions - **BSMA1001-maths-1:** Integration techniques (substitution, by parts) - **BSMA1004 (Stats 2):** Continuous distributions in statistical inference [Join Discord](https://discord.gg/gE2m4Qrdqv) [Previous**Discrete Random Variables**](/notes/01-foundation-bsma1002-stats-1-week09-15-discrete-random-variables)[Next**Expectation & Variance**](/notes/01-foundation-bsma1002-stats-1-week10-17-expectation-variance)
Document outline

Keep your place and jump directly to a heading.

Table of Contents
System Normal // Awaiting Context

Intelligence Hub

Navigate the knowledge graph to generate context. The Hub adapts dynamically to surface backlinks, related notes, and metadata insights.