A continuous random variable is a random variable \(X\) for which \(P(X = x) = 0\) for every point \(x \in \mathbb{R},\) but there are intervals \((a, b)\) over which \(P(X \in (a, b)) > 0.\)
Example: Random events that happen in real time are represented using continuous random variables. For example, let \(T\) be the amount of time after \(12:00\)pm until a company gets it's first customer service phone call for the day. The probability that the first phone call takes exactly \(1\) minute is \(0\), because it is impossible to measure so precisely. What if the first phone call comes at \(1\) minute and \(0.0000000001\) seconds? However, it is possible to measure whether the first phone call comes in between \(1\) minute and \(1\) minute \(5\) seconds.
Probability Density Function (pdf)
The probability density fucntion (pdf) of a continuous random variable \(X\) is similar to the pmf, but sums are replaced by integrals.
The pdf of \(X\) is a function \(f\) such that
\[P(X \in A) = \int_A f(x)dx\]
Example: Let \(X\) be a continuous random variable with pdf \(f(x) = \frac{1}{2}x\) for \(0 \leq x \leq 2.\) Find the probability that \(1 < X < 2.\)
The event \(\{1 < X < 2\}\) is equivalent to the event \(\{X \in (1, 2)\},\) so we can directly compute:
\begin{align}
P(X \in (1,2)) & = \int_{(1,2)} f(x) dx \\
& = \int_1^2 \frac{1}{2} x dx \\
& = \left. \frac{1}{4} x^2 \right|_1^2 \\
& = \frac{1}{4} \cdot 2^2 - \frac{1}{4} \cdot 1^2 \\
& = \frac{3}{4}
\end{align}
Properties of the pdf
The pdf represents a way to compute probabilities, so there are certain properties that it must satisfy.
Probabilities are always non-negative, so a pdf must always be non-negative. For example, \(f(x) = x\) cannot be a pdf because \(f(-1) = -1 < 0.\)
A random variable \(X\) always satisfies \(P(X \in \mathbb{R}) = 1,\) so the pdf must satisfy
\[P(X \in \mathbb{R}) = \int_{-\infty}^\infty f(x)dx = 1\]
So a function like \(f(x) = x\) when \(x > 0\) and \(f(x) = 0\) when \(x < 0\) cannot be a pdf, because
\[\int_{-\infty}^\infty f(x)dx = \int_{0}^\infty x dx = \infty\]
The function \(f(x) = x\) when \(0 < x < \sqrt{2}\) and \(f(x) = 0\) otherwise is a pdf because \(f(x) \geq 0\) for all \(x\) and
\begin{align}
\int_{-\infty}^\infty f(x)dx & = \int_{0}^{\sqrt{2}} x dx = \\
& \left. \frac{x^2}{2} \right|_0^\sqrt{2} \\
& = \frac{\sqrt{2}^2}{2} - \frac{0^2}{2}\\
& = 1
\end{align}
Check your understanding:
Let \(X\) be a continuous random variable with pdf \(f(x)\) defined by \(f(x) = \frac{2+x}{3}\) for \(-1 < x < 0\) and \(f(x) = \frac{2-x}{3}\) for \(0 \leq x < 1.\)
1. What is \(P(X = 0)?\)
Unanswered
Solution: Since \(X\) is a continuous random variable, the probability that \(X\) equals a particular value is \(0.\) So, \(P(X = 0) = 0.\)
2. What is \(P(X < 0)?\)
Unanswered
Solution: The pdf of \(X\) is non-zero over \((-\infty, 0)\) on \((-1, 0).\) So,
\begin{align}
P(X < 0) & = \int_{-1}^0 \frac{2+x}{3} dx \\
& = \left. \frac{2}{3}x + \frac{1}{6}x^2 \right|_{x = -1}^0 \\
& = \frac{2}{3} - \frac{1}{6} \\
& = 0.5
\end{align}
3. What is \(P(X > 0.5)?\)
Unanswered
Solution: The pdf of \(X\) is non-zero over \((0.5, \infty)\) on \((0.5, 1).\) So,
\begin{align}
P(X > 0.5) & = \int_{0.5}^1 \frac{2-x}{3} dx \\
& = \left. \frac{2}{3}x - \frac{1}{6}x^2 \right|_{0.5}^1 \\
& = \frac{2}{3} - \frac{1}{6} - \frac{1}{3} + \frac{1}{24} \\
& \approx 0.21
\end{align}
4. What is \(P(|X| < 0.25)?\)
Unanswered
Solution: The event \(\{|X| < 0.25\}\) is the same as the event \(\{-0.25 < X < 0\} \cup \{0 \leq X < 0.25\}.\) So,
\begin{align}
P(|X| < 0.25) & = \int_{-0.25}^0 \frac{2+x}{3}dx + \int_0^{0.25} \frac{2-x}{3}dx \\
& = \left(\left. \frac{2}{3}x + \frac{1}{6}x^2\right|_{-0.25}^0\right) + \left(\left. \frac{2}{3}x + \frac{1}{6}x^2\right|_0^{0.25}\right) \\
& = \left(\frac{1}{6} - \frac{1}{96}\right) + \left(\frac{1}{6} - \frac{1}{96}\right) \\
& \approx 0.31
\end{align}