Continuous distributions and density functions Dr. Konrad Völkel
Heinrich Heine University Düsseldorf
Let X : Ω → R X \colon \Omega \to \mathbb{R} X : Ω → R be a random variable, that is, let Ω \Omega Ω be a probability space (a set Ω \Omega Ω together with a probability measure P Ω P_\Omega P Ω ) and let X X X be a map such that P ( X ∈ A ) : = P Ω ( X − 1 ( A ) ) P(X \in A) := P_\Omega(X^{-1}(A)) P ( X ∈ A ) := P Ω ( X − 1 ( A )) is defined for all events A ⊆ R A \subseteq \mathbb{R} A ⊆ R .
If Ω \Omega Ω is not a discrete probability space (because Ω \Omega Ω is uncountably infinite, say Ω = R n \Omega = \mathbb{R}^n Ω = R n ), if X X X takes uncountably many possible values, and if the distribution of X X X has a density (defined in the next section), then we call X X X a continuous random variable . A random variable with uncountably many values but no density – a mixture of a Dirac and a normal distribution, for instance – is therefore neither discrete nor continuous.
The word closed is not decoration here. Without it the intersection would be empty for every distribution with a density: for X ∼ U ( [ 0 , 1 ] ) X \sim U([0,1]) X ∼ U ([ 0 , 1 ]) the set [ 0 , 1 ] ∖ { x } [0,1] \setminus \{x\} [ 0 , 1 ] ∖ { x } still has probability 1 for every single x x x (individual points are null sets – more on that shortly), so no point at all would lie in all of these sets. Insist on closed sets and [ 0 , 1 ] [0,1] [ 0 , 1 ] comes out, as it should. (That the intersection itself has probability 1 again, because countably many of the A A A already suffice, is something we will not need.)
Every interval of the form [ a , b ] [a,b] [ a , b ] is closed, for instance, as is all of R \mathbb{R} R and every finite set. The interval ( 0 , 1 ] (0,1] ( 0 , 1 ] , by contrast, is not: the sequence 1 k \frac1k k 1 lies in it, its limit 0 does not. The closure of ( 0 , 1 ] (0,1] ( 0 , 1 ] is [ 0 , 1 ] [0,1] [ 0 , 1 ] .
For a discrete distribution with pmf p p p and finitely many values, the support simplifies to
supp ( X ) = { x ∣ p ( x ) > 0 } , \operatorname{supp}(X) = \{\, x \ \mid\ p(x) > 0 \,\}, supp ( X ) = { x ∣ p ( x ) > 0 } , that is, to the set of values that can occur at all (with infinitely many values, their accumulation points come along too, since the support is closed).
The uniform distribution on Ω = { 1 , … , n } \Omega = \{1,\dots,n\} Ω = { 1 , … , n } , read as a distribution on Ω \Omega Ω , has support Ω \Omega Ω itself – every element of it is possible.
The same distribution can also be read as a distribution on R \mathbb{R} R , by giving every other real number probability 0. Then the support is { 1 , … , n } ⊂ R \{1,\dots,n\} \subset \mathbb{R} { 1 , … , n } ⊂ R , a finite and hence closed subset of the reals. So the support depends not only on the distribution, but also on what you read it as a distribution on.
The support is defined for discrete real random variables too – the obvious difference being that the support of a discrete random variable contains no interval.
Density functions ¶ Let D ⊆ R n D \subseteq \mathbb{R}^n D ⊆ R n and let f : D → [ 0 , ∞ ) f \colon D \to [0,\infty) f : D → [ 0 , ∞ ) be an integrable function (with respect to the Lebesgue measure on R n \mathbb{R}^n R n ; Riemann integrability suffices) with ∫ D f ( x ) d x = 1 \int_D f(x) dx = 1 ∫ D f ( x ) d x = 1 . Then a probability measure on D D D is defined by:
for an event A ⊆ D : P ( A ) : = ∫ A f ( x ) d x \text{for an event } A \subseteq D \colon \quad P(A) := \int_A f(x) dx for an event A ⊆ D : P ( A ) := ∫ A f ( x ) d x Whenever a probability measure P P P can be written in this way, we call the function f f f a probability density function (pdf), or a density for short (not to be confused with the probability mass function, pmf, of the discrete case).
So for a real random variable X : Ω → R X \colon \Omega \to \mathbb{R} X : Ω → R whose distribution P X P_X P X has a density f f f , we have for A ⊆ R A \subseteq \mathbb{R} A ⊆ R
∫ X − 1 ( A ) d P ( ω ) = P ( X ∈ A ) = P X ( A ) = ∫ A f ( x ) d x \int_{X^{-1}(A)} dP(\omega) = P(X \in A) = P_X(A) = \int_A f(x) dx ∫ X − 1 ( A ) d P ( ω ) = P ( X ∈ A ) = P X ( A ) = ∫ A f ( x ) d x The integral on the right is now an integral over the range of X X X .
In the same way we can also compute the expected value and the variance:
Let X X X be a continuous random variable whose distribution is given by a density f : D → [ 0 , ∞ ) f \colon D \to [0,\infty) f : D → [ 0 , ∞ ) . Then
E ( X ) = ∫ Ω X ( ω ) d P ( ω ) = ∫ D x f ( x ) d x \mathbb{E}(X) = \int_\Omega X(\omega)\, dP(\omega) = \int_D x f(x) dx E ( X ) = ∫ Ω X ( ω ) d P ( ω ) = ∫ D x f ( x ) d x is called the expected value of X X X , and
V ( X ) = ∫ Ω ( X ( ω ) − E ( X ) ) 2 d P ( ω ) = ∫ D ( x − E ( X ) ) 2 f ( x ) d x \mathbb{V}(X) = \int_\Omega \left(X(\omega)-\mathbb{E}(X)\right)^2 dP(\omega) = \int_D \left(x-\mathbb{E}(X)\right)^2 f(x) dx V ( X ) = ∫ Ω ( X ( ω ) − E ( X ) ) 2 d P ( ω ) = ∫ D ( x − E ( X ) ) 2 f ( x ) d x the variance of X X X , provided these integrals exist. For D = R D = \mathbb{R} D = R , for example, E ( X ) = ∫ − ∞ ∞ x f ( x ) d x \mathbb{E}(X) = \int_{-\infty}^{\infty} x f(x) dx E ( X ) = ∫ − ∞ ∞ x f ( x ) d x .
This is the continuous counterpart of the sum over the probability mass function in the chapter Expected value and variance : the density takes the place of the pmf, the integral the place of the sum. That other functions of X X X may be integrated in the same way is what the following theorem says.
Let X X X be a continuous random variable with density f : D → [ 0 , ∞ ) f \colon D \to [0,\infty) f : D → [ 0 , ∞ ) and let g : D → R g \colon D \to \mathbb{R} g : D → R be a (measurable) function. Then
E ( g ( X ) ) = ∫ D g ( x ) f ( x ) d x , \mathbb{E}(g(X)) = \int_D g(x) f(x) dx, E ( g ( X )) = ∫ D g ( x ) f ( x ) d x , provided the integral exists. For a discrete random variable with pmf p p p , the same statement reads E ( g ( X ) ) = ∑ x g ( x ) p ( x ) \mathbb{E}(g(X)) = \sum_x g(x)\, p(x) E ( g ( X )) = ∑ x g ( x ) p ( x ) .
We do not prove the theorem (it follows from the change-of-variables theorem for integrals), but we use it constantly: the definition of the variance is precisely the special case g ( x ) = ( x − E ( X ) ) 2 g(x) = (x - \mathbb{E}(X))^2 g ( x ) = ( x − E ( X ) ) 2 , and with g ( x ) = x 2 g(x) = x^2 g ( x ) = x 2 we obtain, as in the discrete case,
V ( X ) = E ( X 2 ) − ( E ( X ) ) 2 = ∫ D x 2 f ( x ) d x − ( E ( X ) ) 2 . \mathbb{V}(X) = \mathbb{E}(X^2) - {\left( \mathbb{E}(X) \right)}^2 = \int_D x^2 f(x) dx - {\left( \mathbb{E}(X) \right)}^2. V ( X ) = E ( X 2 ) − ( E ( X ) ) 2 = ∫ D x 2 f ( x ) d x − ( E ( X ) ) 2 . In general, E ( X k ) = ∫ D x k f ( x ) d x \mathbb{E}(X^k) = \int_D x^k f(x) dx E ( X k ) = ∫ D x k f ( x ) d x is called the k k k -th moment of X X X .
Let a < b ∈ R a < b \in \mathbb{R} a < b ∈ R . Take D = R D = \mathbb{R} D = R and f : R → [ 0 , ∞ ) f \colon \mathbb{R} \to [0,\infty) f : R → [ 0 , ∞ ) given by
f ( x ) = { 1 b − a , if x ∈ [ a , b ] 0 otherwise f(x) = \begin{cases} \frac{1}{b-a}, & \text{ if } x \in [a,b] \\ 0 & \text{ otherwise} \end{cases} f ( x ) = { b − a 1 , 0 if x ∈ [ a , b ] otherwise This f f f defines a probability measure on R \mathbb{R} R , the continuous uniform distribution on the interval [ a , b ] [a,b] [ a , b ] .
Let X X X be a random variable with this distribution; we write X ∼ U ( [ a , b ] ) X \sim U([a,b]) X ∼ U ([ a , b ]) .
Its expected value (using ∫ x d x = x 2 2 \int x dx = \frac{x^2}{2} ∫ x d x = 2 x 2 ) is E ( X ) = \mathbb{E}(X) = E ( X ) =
∫ − ∞ ∞ x f ( x ) d x = ∫ a b x d x b − a = 1 b − a [ x 2 2 ] a b = b 2 − a 2 2 ( b − a ) = ( b + a ) ( b − a ) 2 ( b − a ) = a + b 2 \int_{-\infty}^{\infty} xf(x) dx = \int_a^b \frac{xdx}{b-a} = \frac{1}{b-a} \left[\frac{x^2}{2}\right]_a^b = \frac{b^2 -a^2}{2(b-a)} = \frac{(b+a)(b-a)}{2(b-a)} = \frac{a+b}{2} ∫ − ∞ ∞ x f ( x ) d x = ∫ a b b − a x d x = b − a 1 [ 2 x 2 ] a b = 2 ( b − a ) b 2 − a 2 = 2 ( b − a ) ( b + a ) ( b − a ) = 2 a + b The second moment is
E ( X 2 ) = ∫ − ∞ ∞ x 2 f ( x ) d x = [ x 3 3 ( b − a ) ] a b = b 3 − a 3 3 ( b − a ) = a 2 + a b + b 2 3 \mathbb{E}(X^2) = \int_{-\infty}^\infty x^2 f(x)dx = \left[ \frac{x^3}{3(b-a)} \right]_a^b = \frac{b^3-a^3}{3(b-a)} = \frac{a^2+ab+b^2}{3} E ( X 2 ) = ∫ − ∞ ∞ x 2 f ( x ) d x = [ 3 ( b − a ) x 3 ] a b = 3 ( b − a ) b 3 − a 3 = 3 a 2 + ab + b 2 The variance is
V ( X ) = E ( X 2 ) − ( E ( X ) ) 2 = a 2 + a b + b 2 3 − ( a + b ) 2 4 = ( a − b ) 2 12 \mathbb{V}(X) = \mathbb{E}(X^2) - {\left(\mathbb{E}(X)\right)}^2 = \frac{a^2+ab+b^2}{3} - \frac{(a+b)^2}{4} = \frac{(a-b)^2}{12} V ( X ) = E ( X 2 ) − ( E ( X ) ) 2 = 3 a 2 + ab + b 2 − 4 ( a + b ) 2 = 12 ( a − b ) 2 Null sets. For X ∼ U ( [ a , b ] ) X \sim U([a,b]) X ∼ U ([ a , b ]) and a ≤ c < d ≤ b a \leq c < d \leq b a ≤ c < d ≤ b we have P ( c ≤ X ≤ d ) = ∫ c d d x b − a = d − c b − a P(c \leq X \leq d) = \int_c^d \frac{dx}{b-a} = \frac{d-c}{b-a} P ( c ≤ X ≤ d ) = ∫ c d b − a d x = b − a d − c , and the same integral comes out for P ( c < X < d ) P(c < X < d) P ( c < X < d ) , P ( c ≤ X < d ) P(c \leq X < d) P ( c ≤ X < d ) and P ( c < X ≤ d ) P(c < X \leq d) P ( c < X ≤ d ) : whether or not the endpoints belong to the interval makes no difference to the integral. In particular P ( X = c ) = ∫ c c f ( x ) d x = 0 P(X = c) = \int_c^c f(x) dx = 0 P ( X = c ) = ∫ c c f ( x ) d x = 0 for every single point c c c , even though f ( c ) = 1 b − a ≠ 0 f(c) = \frac{1}{b-a} \neq 0 f ( c ) = b − a 1 = 0 .
This holds for every distribution with a density: individual points have probability 0; by finite additivity so does every finite set; and by the σ \sigma σ -additivity from the chapter Deriving the mathematical formalism of stochastics so does every countable set A = { a 1 , a 2 , … } A = \{a_1, a_2, \dots\} A = { a 1 , a 2 , … } , since P ( X ∈ A ) = ∑ i P ( X = a i ) = 0 P(X \in A) = \sum_{i} P(X = a_i) = 0 P ( X ∈ A ) = ∑ i P ( X = a i ) = 0 . Sets with probability 0 are called null sets . Change a density f f f on a null set (at finitely many points, say) and not one integral ∫ A f ( x ) d x \int_A f(x) dx ∫ A f ( x ) d x changes – and so neither does the probability measure it defines.
The set Q ∩ [ 0 , 1 ] \mathbb{Q} \cap [0,1] Q ∩ [ 0 , 1 ] of rational numbers between 0 and 1 is countable, and hence a null set for X ∼ U ( [ 0 , 1 ] ) X \sim U([0,1]) X ∼ U ([ 0 , 1 ]) : a uniformly distributed random number from [ 0 , 1 ] [0,1] [ 0 , 1 ] is irrational with probability 1. A puzzle: is there any distribution on [ 0 , 1 ] [0,1] [ 0 , 1 ] at all that gives every single point positive probability? (No: for each k k k there are at most k k k points with probability at least 1 k \frac{1}{k} k 1 , so at most countably many points in all with positive probability.)
Not every probability measure can be represented by a density:
consider the distribution on R \mathbb{R} R with
P ( A ) = { 1 if 0 ∈ A 0 otherwise P(A) = \begin{cases} 1 & \text{ if } 0 \in A \\ 0 & \text{ otherwise} \end{cases} P ( A ) = { 1 0 if 0 ∈ A otherwise This distribution is called the Dirac distribution with mass at 0. There can be no density f f f for it: the one-point set { 0 } \{0\} { 0 } is a null set for every density, so we would have ∫ { 0 } f ( x ) d x = 0 ≠ 1 = P ( { 0 } ) \int_{\{0\}} f(x) dx = 0 \neq 1 = P(\{0\}) ∫ { 0 } f ( x ) d x = 0 = 1 = P ({ 0 }) . The same argument hits every discrete distribution on R \mathbb{R} R : it concentrates its whole mass 1 on its countable support, and that is a null set for every density. If you go to great lengths to build something density-like anyway, you end up in the theory of distributions – generalised functions – from functional analysis (physicists know them). And there are probability distributions for which not even a generalised function will do.
Conversely, a continuous distribution is easily built out of a discrete one. Let Y Y Y be a discrete random variable with values in { 5 , 6 , 7 } \{5,6,7\} { 5 , 6 , 7 } and P ( Y = 5 ) = 4 7 P(Y=5) = \frac{4}{7} P ( Y = 5 ) = 7 4 , P ( Y = 6 ) = 2 7 P(Y=6) = \frac{2}{7} P ( Y = 6 ) = 7 2 , P ( Y = 7 ) = 1 7 P(Y=7) = \frac{1}{7} P ( Y = 7 ) = 7 1 , and let Z ∼ U ( [ 0 , 1 ) ) Z \sim U([0,1)) Z ∼ U ([ 0 , 1 )) be independent of Y Y Y (formally: Ω = { 5 , 6 , 7 } × [ 0 , 1 ) \Omega = \{5,6,7\} \times [0,1) Ω = { 5 , 6 , 7 } × [ 0 , 1 ) with the product measure, X ( y , z ) = y + z X(y,z) = y + z X ( y , z ) = y + z ). Then X : = Y + Z X := Y + Z X := Y + Z is a continuous random variable with values in [ 5 , 8 ) [5,8) [ 5 , 8 ) and density
f ( x ) = { 4 7 , if x ∈ [ 5 , 6 ) 2 7 , if x ∈ [ 6 , 7 ) 1 7 , if x ∈ [ 7 , 8 ) 0 otherwise, f(x) = \begin{cases} \frac{4}{7}, & \text{ if } x \in [5,6) \\ \frac{2}{7}, & \text{ if } x \in [6,7) \\ \frac{1}{7}, & \text{ if } x \in [7,8) \\ 0 & \text{ otherwise,} \end{cases} f ( x ) = ⎩ ⎨ ⎧ 7 4 , 7 2 , 7 1 , 0 if x ∈ [ 5 , 6 ) if x ∈ [ 6 , 7 ) if x ∈ [ 7 , 8 ) otherwise, since for x ∈ [ 5 , 6 ) x \in [5,6) x ∈ [ 5 , 6 ) we have P ( 5 ≤ X ≤ x ) = P ( Y = 5 ) ⋅ P ( Z ≤ x − 5 ) = 4 7 ( x − 5 ) P(5 \leq X \leq x) = P(Y = 5) \cdot P(Z \leq x - 5) = \frac{4}{7}(x-5) P ( 5 ≤ X ≤ x ) = P ( Y = 5 ) ⋅ P ( Z ≤ x − 5 ) = 7 4 ( x − 5 ) , and likewise on the other two subintervals. The density integrates to 4 7 + 2 7 + 1 7 = 1 \frac{4}{7} + \frac{2}{7} + \frac{1}{7} = 1 7 4 + 7 2 + 7 1 = 1 ; what value f f f takes at the points 6 and 7 does not matter, by the remark on null sets. For example P ( 5 ≤ X ≤ 6 ) = ∫ 5 6 f ( x ) d x = 4 7 P(5 \leq X \leq 6) = \int_5^6 f(x) dx = \frac{4}{7} P ( 5 ≤ X ≤ 6 ) = ∫ 5 6 f ( x ) d x = 7 4 and P ( 6 ≤ X ≤ 6.5 ) = 2 7 ⋅ 1 2 = 1 7 P(6 \leq X \leq 6.5) = \frac{2}{7} \cdot \frac{1}{2} = \frac{1}{7} P ( 6 ≤ X ≤ 6.5 ) = 7 2 ⋅ 2 1 = 7 1 . The expected value is
E ( X ) = ∫ 5 8 x f ( x ) d x = 4 7 ⋅ 11 2 + 2 7 ⋅ 13 2 + 1 7 ⋅ 15 2 = 85 14 = 6 + 1 14 , \mathbb{E}(X) = \int_5^8 x f(x) dx = \frac{4}{7} \cdot \frac{11}{2} + \frac{2}{7} \cdot \frac{13}{2} + \frac{1}{7} \cdot \frac{15}{2} = \frac{85}{14} = 6 + \frac{1}{14}, E ( X ) = ∫ 5 8 x f ( x ) d x = 7 4 ⋅ 2 11 + 7 2 ⋅ 2 13 + 7 1 ⋅ 2 15 = 14 85 = 6 + 14 1 , since on every subinterval [ k , k + 1 ) [k, k+1) [ k , k + 1 ) we have ∫ k k + 1 x d x = k + 1 2 \int_k^{k+1} x\, dx = k + \frac{1}{2} ∫ k k + 1 x d x = k + 2 1 (the same comes out of E ( Y ) + E ( Z ) = 39 7 + 1 2 \mathbb{E}(Y) + \mathbb{E}(Z) = \frac{39}{7} + \frac{1}{2} E ( Y ) + E ( Z ) = 7 39 + 2 1 ). A distribution like this – a discrete choice first, then a continuous one within the chosen class – is called a mixture distribution ; another example is the contaminated normal distribution in the chapter The most important continuous distributions , where this very distribution on [ 5 , 8 ) [5,8) [ 5 , 8 ) is simulated too.
Let ( Ω , P ) (\Omega, P) ( Ω , P ) be a probability space. Then for a random variable X : Ω → R X \colon \Omega \to \mathbb{R} X : Ω → R we call the function
F : R → [ 0 , 1 ] , x ↦ P ( X ≤ x ) F \colon \mathbb{R} \to [0,1],\qquad x \mapsto P(X \leq x) F : R → [ 0 , 1 ] , x ↦ P ( X ≤ x ) the cumulative probability distribution function , or distribution function , or cdf for short. Unlike the density (pdf), it always exists.
If P X P_X P X has a density f : R → [ 0 , ∞ ) f \colon \mathbb{R} \to [0,\infty) f : R → [ 0 , ∞ ) ,
so that P ( a ≤ X ≤ b ) = ∫ a b f ( x ) d x P(a \leq X \leq b) = \int_a^b f(x)dx P ( a ≤ X ≤ b ) = ∫ a b f ( x ) d x , then
F ( x ) = ∫ − ∞ x f ( t ) d t . F(x) = \int_{-\infty}^{x} f(t)dt. F ( x ) = ∫ − ∞ x f ( t ) d t . Whether you write P ( X ≤ x ) P(X \leq x) P ( X ≤ x ) or P ( X < x ) P(X < x) P ( X < x ) here makes no difference, by the remark on null sets; some books define the cdf with P ( X < x ) P(X < x) P ( X < x ) , and for distributions with a density that is the same function.
If P X P_X P X has a density f f f , then the distribution function F F F is an antiderivative of f f f : by the fundamental theorem of calculus, F F F is differentiable at every point x x x at which f f f is continuous, with F ′ ( x ) = f ( x ) F'(x) = f(x) F ′ ( x ) = f ( x ) . For every random variable (with or without a density) the cdf also gives the probability of intervals,
P ( a < X ≤ b ) = F ( b ) − F ( a ) , P(a < X \leq b) = F(b) - F(a), P ( a < X ≤ b ) = F ( b ) − F ( a ) , and with a density that is precisely ∫ a b f ( t ) d t \int_a^b f(t)dt ∫ a b f ( t ) d t .
So the cdf climbs steeply exactly where the density is large. In the chapter The most important continuous distributions the pdf and the cdf are always plotted together; look out for it there.