Random variables · Definition
Probability density function
Before you start you need to know
It is the tool that spreads probability over the infinitely many possible values of a continuous variable, where assigning mass to each point no longer works.
Definition
The density function \(f\) of a continuous random variable \(X\) is a nonnegative function such that the area under its graph over an interval is the probability \(P\) that \(X\) falls in it.
A continuous variable takes values in an interval, and each isolated value has probability zero: \(P(X=a)=0\). So probability is assigned to intervals, and the density \(f\) is the function whose area makes that possible. It is read as a concentration: where \(f\) is large, the variable falls more often in short intervals around that point.
Every density satisfies two conditions: \(f(x)\ge 0\) and \(\int_{-\infty}^{\infty}f(x)\,dx=1\). When a density comes with an unknown constant, as in \(f(x)=kx\) on \([0,2]\), the second condition determines it: \(2k=1\). Since single points do not count, \(P(a\le X\le b)\) and \(P(a<X<b)\) are equal, unlike the discrete case.
A density is not a probability and can exceed 1: \(f(x)=2\) on \([0,\tfrac12]\) has area 1. What is a probability is the area. If \(f(x)=2x\) on \([0,1]\), then \(P(X\le\tfrac12)=\int_0^{1/2}2x\,dx=\tfrac14\). A typical mistake is reading \(f(a)\) as \(P(X=a)\).
For continuous variables the density plays the role the mass function plays for discrete ones, with integrals in place of sums. Later the cumulative distribution function unifies both cases, and the integral of \(x\,f(x)\) defines the continuous expectation.
Think about it
Why is \(P(X=a)=0\) for a continuous variable, and yet \(X\) takes some value?
Because the area over a single point is zero; the total probability 1 is spread over infinitely many values and only intervals receive positive area.
A density is \(f(x)=5\) on \([0,0.2]\). Is it valid?
Yes: it is nonnegative and its area is \(5\cdot 0.2=1\). Exceeding 1 is not a problem.
Exercises 10
- A continuous variable has density \(f(x)=kx\) for \(0\le x\le 2\) and 0 elsewhere. What is \(k\)?
- If \(X\) has density \(f(x)=2x\) on \([0,1]\), what is \(P(X\le \tfrac12)\)?
- \(X\) has constant density \(f(x)=\tfrac14\) on \([0,4]\). What is \(P(1\le X\le 3)\)?
- If \(X\) is continuous with density \(f\), what is \(P(X=2)\)?
- \(X\) has density \(f(x)=3x^2\) on \([0,1]\). Compute \(P(X>\tfrac12)\).
- \(X\) has density \(f(x)=e^{-x}\) for \(x\ge 0\). What is \(P(X>2)\)?
- Which of these functions, equal to 0 outside its interval, is a density?
- Which statement about a density \(f\) is true?
- \(X\) has density \(f(x)=6x(1-x)\) on \([0,1]\). Compute \(P(\tfrac14\le X\le\tfrac34)\).
- \(f(x)=c(1-x^2)\) on \([-1,1]\) and 0 elsewhere is a density. What is \(c\)?
References
- Joseph K. Blitzstein, Jessica Hwang, Introduction to Probability, 2nd edition, CRC Press, 2019. §5.1
- Sheldon Ross, A First Course in Probability, 10th edition, Pearson, 2019. §5.1
- Ronald E. Walpole, Raymond H. Myers, Sharon L. Myers, Keying Ye, Probabilidad y estadística para ingeniería y ciencias, 9.ª edición, Pearson, 2012. §3.3