Continuous Random Variables — PDF, CDF, and Properties
1975 words
10 min read
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)=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) can be > 0. For continuous RVs, P(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) describes the relative likelihood of a continuous random variable taking on a value near x.
Properties:
- f(x)≥0 for all x (density can't be negative)
- ∫−∞∞f(x)dx=1 (total area under the PDF = 1)
- P(a≤X≤b)=∫abf(x)dx (probability = area under curve)
17.2.2 Important: PDF ≠ Probability
The PDF f(x) is not a probability. Probabilities for continuous RVs are always areas (integrals). The value f(a) is a density, not a probability.
17.3 Cumulative Distribution Function (CDF)
17.3.1 Definition
F(x)=P(X≤x)=∫−∞xf(t)dtProperties:
- F′(x)=f(x) (the derivative of the CDF is the PDF)
- limx→−∞F(x)=0
- limx→+∞F(x)=1
- P(a<X<b)=F(b)−F(a)
17.4 Expected Value and Variance
Expected Value
E(X)=μ=∫−∞∞x⋅f(x)dxExpected Value of a Function
E(g(X))=∫−∞∞g(x)⋅f(x)dxVariance
Var(X)=σ2=∫−∞∞(x−μ)2f(x)dx=E(X2)−[E(X)]2Standard Deviation
σX=Var(X)17.5 Worked Examples
Example 1: Validating a PDF (Easy)
Scenario: f(x)=kx for 0≤x≤2, 0 otherwise. Find k so this is a valid PDF.
Solution:
Condition: ∫−∞∞f(x)dx=1
So k=1/2. The valid PDF is f(x)=x/2 for 0≤x≤2.
Example 2: Computing a Probability (Medium)
Scenario: X has PDF
Find P(0≤X≤0.5).
Solution:
Example 3: Expected Value and Variance (Harder)
Scenario: f(x)=23x2 for −1≤x≤1, 0 otherwise.
Find E(X), E(X2), and Var(X).
Solution:
17.6 Percentiles and Median
The p-th percentile is the value xp such that F(xp)=p/100.
The median is the 50th percentile: F(median)=0.5.
Example: For f(x)=x/2 on [0,2], find the median.
Set F(x)=0.5: 4x2=0.5, x2=2, x=2≈1.414
The median is approximately 1.414.
17.7 Discrete vs. Continuous — Summary Table
| Property | Discrete | Continuous |
|---|---|---|
| Probability at a point | P(X=x)≥0 | P(X=x)=0 |
| Distribution | PMF p(x) | PDF f(x) |
| CDF | F(x)=∑t≤xp(t) | F(x)=∫−∞xf(t)dt |
| P(a≤X≤b) | ∑x=abp(x) | ∫abf(x)dx |
| Expected value | ∑x⋅p(x) | ∫x⋅f(x)dx |
| Values | Countable | Uncountable (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
| Concept | Formula | Notes |
|---|---|---|
| PDF properties | f(x)≥0 , ∫f(x)dx=1 | Density, not probability |
| Probability via PDF | P(a≤X≤b)=∫abf(x)dx | Area under curve |
| CDF | F(x)=∫−∞xf(t)dt | Non-decreasing |
| PDF from CDF | f(x)=F′(x) | Derivative |
| Expected Value | E(X)=∫−∞∞xf(x)dx | Center of mass |
| Variance | Var(X)=E(X2)−[E(X)]2 | Spread |
| Median | F(median)=0.5 | 50th percentile |
⚠️ Common Pitfalls
Pitfall 1: Thinking f(x) Is a Probability
The mistake: Saying P(X=1.5)=f(1.5).
Correction: For continuous variables, P(X=a)=0 always. The PDF 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. If not, scale it (find the normalization constant).
Pitfall 3: Using Summation Instead of Integration
The mistake: Writing E(X)=∑xf(x) for continuous variables.
Correction: For continuous, use ∫xf(x)dx. Summation is for discrete.
📝 Practice Questions
</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,x3,1,x<00≤x≤1x>1></strong>Q1: PDF Validation<details> <strong>Solution</strong>Is f(x)=2x for 0≤x≤1 a valid PDF?f(x)≥0 ✓ for x∈[0,1]∫012xdx=[x2]01=1−0=1 ✓Yes, it's a valid PDF.
>f(x)=F′(x)={3x2,0,0≤x≤1otherwise><details> <strong>Solution</strong>Find the PDF f(x) and P(0.2≤X≤0.5).PDF:
</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)P(0.2≤X≤0.5): =F(0.5)−F(0.2)=(0.5)3−(0.2)3=0.125−0.008=0.117f(x)=3x2, P=0.117