Continuous Random Variables: Density, PMF F (X) Density, PDF F (Y) Y/6, 2 y 4
Continuous Random Variables: Density, PMF F (X) Density, PDF F (Y) Y/6, 2 y 4
Continuous Random Variables: Density, PMF F (X) Density, PDF F (Y) Y/6, 2 y 4
3.1 Introduction
Rather than summing probabilities related to discrete random variables, here for
continuous random variables, the density curve is integrated to determine probability.
0 1 2 0 1 2 3 4 x
0 1 2 0 1 2 3 4 x
73
74 Chapter 3. Continuous Random Variables (LECTURE NOTES 5)
2. Discrete
3. Continuous
3.2 Definitions
Random variable X is continuous if probability density function (pdf) f is continuous
at all but a finite number of points and possesses the following properties:
• f (x) ≥ 0, for all x,
R∞
• −∞ f (x) dx = 1,
Rb
• P (a < X ≤ b) = a f (x) dx
The (cumulative) distribution function (cdf) for random variable X is
Z x
F (x) = P (X ≤ x) = f (t) dt,
−∞
f(x) is positive
density, f(x)
probability probability
_ a)
cdf F(a) = P(X < total area = 1
_ b) = F(b) - F(a)
P(a < X <
a x a b
the variance is
√
with associated standard deviation, σ = σ2.
The moment-generating function is
Z ∞
M (t) = E etX = etX f (x) dx
−∞
and where πp is also called the quantile of order p. The 25th, 50th, 75th percentiles
are also called first, second, third quartiles, denoted p1 = π0.25 , p2 = π0.50 , p3 = π0.75
where also 50th percentile is called the median and denoted m = p2 . The mode is the
value x where f is maximum.
1. Waiting time.
Let the time waiting in line, in minutes, be described by the random variable
X which has the following pdf,
1
6
x, 2 < x ≤ 4,
f (x) =
0, otherwise.
0 1 2 3 4 x 0 1 2 3 4 x
(e) P (0 < X ≤ 3) =
3 x=3
x2 32 22
Z
1
x dx = = − =
2 6 12 x=2 12 12
5 9
(i) 0 (ii) 12
(iii) 12 (iv) 1
Why integrate from 2 to 3 and not 0 to 3?
(f) P (X ≤ 3) =
3 x=3
x2 32 22
Z
1
x dx = = − =
2 6 12 x=2 12 12
5 9
(i) 0 (ii) 12
(iii) 12
(iv) 1
(g) Determine cdf (not pdf) F (3).
3 x=3
x2 32 22
Z
1
F (3) = P (X ≤ 3) = x dx = = − =
2 6 12 x=2 12 12
5 9
(i) 0 (ii) 12
(iii) 12
(iv) 1
(h) Determine F (3) − F (2).
3 x=3
x2 32 22
Z
1
F (3)−F (2) = P (X ≤ 3)−P (X ≤ 2) = P (2 ≤ X ≤ 3) = x dx = = − =
2 6 12 x=2 12 12
5 9
(i) 0 (ii) 12
(iii) 12 (iv) 1
because everything left of (below) 3 subtract everything left of 2 equals what is between 2 and 3
78 Chapter 3. Continuous Random Variables (LECTURE NOTES 5)
[1] 3.111111
[1] 28/9
[1] 26/81
[1] 26/81
(r) Standard deviation. Standard deviation in time spent on the call is,
√
r
26
σ = σ2 = ≈
81
x2 −4
(t) Median. Since the distribution function F (x) = 12
, then median m =
π0.50 occurs when
m2 − 4 1
F (m) = P (X ≤ m) = =
12 2
so r
12
m = π0.50 = +4≈
2
(i) 1.16 (ii) 2.16 (iii) 3.16
negative answer m ≈ −3.16 is not in 2 < x ≤ 4, so m 6= −3.16
0.25 0.25
0 1 2 3 4 5 x 0 1 2 3 4 5 x
then
a(53 − 1) 124a
F (5) = = = 1,
3 3
3 2 1
so a = (i) 124
(ii) 124
(iii) 124
(b) Determine pdf.
f (x) = ax2 =
3 2 1
(i) 124
x2 (ii) 124
x2 (iii) 124
x2
Section 2. Definitions (LECTURE NOTES 5) 81
1
Since F (x) = 124
(x3 − 1), then,
1 3 1
F (π0.25 ) = (π0.25 − 1) = 0.25 = ,
124 4
and so r
3 124
π0.25 = +1≈
4
(i) 2.38 (ii) 3.17 (iii) 4.17
The π0.25 is that value where 25% of probability is at or below (to the left of) this value.
82 Chapter 3. Continuous Random Variables (LECTURE NOTES 5)
0.75 0.75
0.50 0.50
0.25 0.25
0 1 2 x 1 x
0 2 3
(b) E (X 2 ).
Z 1 Z 2
2 2
x2 (2 − x) dx
E X = x (x) dx +
Z0 1 Z 2 1
x3 dx + 2x2 − x3 dx
=
0 1
4 1 3 2
x 2x x4
= + −
4 0 3 4 1
4 4
2(2)3 24 2(1)3 14
1 0
= − + − − − =
4 4 3 4 3 4
4 5 6
(i) 6
(ii) 6
(iii) 6
(iv) 76 .
(c) Variance.
7
σ 2 = Var(X) = E X 2 − µ2 = − 12 =
6
1 1 1 1
(i) 3
(ii) 4
(iii) 5 (iv) 6 .
1 1
F (1) = 2
, so add 2
to F (x) for 1 < x ≤ 2
then median m occurs when
m2
2 = 12 , 0 < x ≤ 1,
2
F (x) = 2m − m2 − 1 = 12 , 1 < x ≤ 2,
1, x > 2.
and its expected value (mean), variance and standard deviation are,
a+b 2 (b − a)2 p
µ = E(X) = , σ = V ar(X) = , σ= V ar(X),
2 12
and moment-generating function is
etb − eta
M (t) = E etX = , t 6= 0.
t(b − a)
The continuous exponential random variable X has density
−λx
λe , x ≥ 0,
f (x) =
0, elsewhere,
distribution function,
0 x < 0,
F (x) =
1 − e−λx x ≥ 0,
and its expected value (mean), variance and standard deviation are,
1 1 1
µ = E(X) = , σ 2 = V (Y ) = , σ= ,
λ λ2 λ
and moment-generating function is
λ
M (t) = E etX =
, t < λ.
λ−t
1
Notice if θ = λ
in the exponential distribution,
1 x x θ
f (x) = e− θ , F (x) = 1 − e− θ , µ = σ = θ, M (t) = .
θ 1 − tθ
1. Uniform: potato weights. An automated process fills one bag after another
with Idaho potatoes. Although each filled bag should weigh 50 pounds, in fact,
because of the differing shapes and weights of each potato, each bag weight, X,
is anywhere from 49 pounds to 51 pounds, with uniform density:
0.5, 49 ≤ x ≤ 51,
f (x) =
0, elsewhere.
0.75 0.75
0.50 0.50
0.25 0.25
x 0 49 50 x
0 49 50 51 51
[1] 0.75
86 Chapter 3. Continuous Random Variables (LECTURE NOTES 5)
[1] 0.75
[1] 0.002478752
= e−(3)(1.13) − e−(3)(1.62) ≈
(i) 0.014 (ii) 0.026 (iii) 0.034 (iv) 0.054.
pexp(1.62,3) - pexp(1.13,3) # exponential P(1.13 < X < 1.62), lambda = 3
[1] 0.02595819
(d) Calculate probability atomic rate between mean and 1 standard deviation
88 Chapter 3. Continuous Random Variables (LECTURE NOTES 5)
or, equivalently,
lim F (b) = lim 1 − e−3b = 1
b→∞ b→∞
0.60, 0.07, 0.66, 0.17, 0.06, 0.14, 0.15, 0.19, 0.07, 0.36
0.85, 0.44, 0.71, 1.02, 0.07, 0.21, 0.16, 0.16, 0.01, 0.88
0.40
0.35
0.30 exponential density curve, pdf, f(x)
relative frequency
0.25
0.20
relative frequency
0.15 histogram approximates
0.10 density curve
0.05
0
0 0.2 0.4 0.6 0.8 1.0 1.2
time-to-decay (microseconds), x
[1] 0.349
µ ≈ x̄ = 0.349,
[1] 0.4401016
(d) Since sample relative frequencies do not closely match exponential with
λ = 2.9 in table, this distribution (i) is (ii) is not a good fit to the data.
Section 4. The Normal Distribution (LECTURE NOTES 5) 91
and its expected value (mean), variance and standard deviation are,
p
E(X) = µ, V ar(X) = σ 2 , σ = V ar(X),
and mgf is
σ 2 t2
M (t) = exp µt + .
2
A normal random variable, X, may be transformed to a standard normal, Z,
1 2
f (z) = √ e−z /2 ,
2π
where “Z is N (0, 1)” and
Z z
1 2
Φ(z) = P (Z ≤ z) = √ e−t /2 dt,
−∞ 2π
t2 /2
where µ = 0, σ = 1 and M (t) = e using the following equation,
X −µ
Z= .
σ
The distribution of this density does not have a closed–form expression and so must be solved using numerical
integration methods. We will use both R and the tables to obtain approximate numerical answers.
f(x)
σ = 16
f(x)
20 year old IQs
σ = 20
x
µ = 100 µ = 120
84 x 100 120 x
100 96
(a) (b)
x x
84 120 96 120
(c) (d)
(a) For the sixteen year old normal distribution, where µ = 100 and σ = 16,
Z ∞
1 2
P (X1 > 84) = √ e−(1/2)[(y−100)/16] dx1 ≈
84 16 2π
[1] 0.8413447
(b) For sixteen year old normal distribution, where µ = 100 and σ = 16,
P (96 < X1 < 120) ≈ (i) 0.4931 (ii) 0.9641 (iii) 0.8413 (iv) 0.3849.
pnorm(120,100,16) - pnorm(96,100,16) # normal P(96 < X < 120), mean = 100, SD = 16
[1] 0.4930566
[1] 0.9640697
[1] 0.3849303
94 Chapter 3. Continuous Random Variables (LECTURE NOTES 5)
P (µ−σ < X < µ+σ) = P (120 − 20 < X < 120 + 20) = P (100 < X < 140) ≈
3. Standard normal.
Normal densities of IQ scores for 16 year olds, X1 , and 20 year olds, X2 ,
1 2
f (x1 ) = √ e−(1/2)[(y−100)/16] ,
16 2π
1 2
f (x2 ) = √ e−(1/2)[(y−120)/20] .
20 2π
Both densities may be transformed to a standard normal with µ = 0 and σ = 1
using the following equation,
Y −µ
Z= .
σ
(a) Since µ = 100 and σ = 16, a 16 year old who has an IQ of 132 is
z = 132−100
16
= (i) 0 (ii) 1 (iii) 2 (iv) 3
standard deviations above the mean IQ, µ = 100.
(b) A 16 year old who has an IQ of 84 is
z = 84−100
16
= (i) −2 (ii) −1 (iii) 0 (iv) 1
standard deviations below the mean IQ, µ = 100.
(c) Since µ = 120 and σ = 20, a 20 year old who has an IQ of 180 is
z = 180−120
20
= (i) 0 (ii) 1 (iii) 2 (iv) 3
standard deviations above the mean IQ, µ = 120.
(d) A 20 year old who has an IQ of 100 is
z = 100−120
20
= (i) −3 (ii) −2 (iii) −1 (iv) 0
standard deviations below the mean IQ, µ = 120.
Section 4. The Normal Distribution (LECTURE NOTES 5) 95
16 year olds
mean 100, SD 16
110
20 year olds
mean 120, SD 20
(e) Although both the 20 year old and 16 year old scored the same, 110, on
an IQ test, the 16 year old is clearly brighter relative to his/her age group
than is the 20 year old relative his/her age group because
110 − 100 110 − 120
z1 = = 0.625 > z2 = = −0.5.
16 20
(i) True (ii) False
(f) The probability a 20 year old has an IQ greater than 90 is
90 − 120
P (X2 > 90) = P Z2 > = P (Z2 > −1.5) ≈
20
(i) 0.93 (ii) 0.95 (iii) 0.97 (iv) 0.99.
1 - pnorm(90,120,20) # normal P(X > 90), mean = 120, SD = 20
1 - pnorm(-1.5) # standard normal P(Z > -1.5), defaults to mean = 0, SD = 1
[1] 0.9331928
(g) The probability a 20 year old has an IQ between 125 and 135 is
125 − 120 135 − 120
P (125 < X2 < 135) = P < Z2 < = P (0.25 < Z2 < 0.75) =
20 20
(i) 0.13 (ii) 0.17 (iii) 0.27 (iv) 0.31.
96 Chapter 3. Continuous Random Variables (LECTURE NOTES 5)
[1] 0.1746663
X = µ + σZ.
[1] 0.1586553
[1] 73.47304
Z≈
dF
f (y) = F 0 (x) = .
du
The second fundamental theorem of calculus is sometimes used in this method,
Z u2 (y)
d du2 du1
fX (x) dx = fX (u2 (y)) − fX (u1 (y)) .
dy u1 (y) dy dy
Related to this is an algorithm for sampling at random values from a random variable
X with a desired distribution by using the uniform distribution:
probability, cdf F(x) = P(X < x) = x - x 2/4 probability, cdf F(y) = P(Y < y) = y/2 - y 2/16
1 1
0.75 0.75
0.50 0.50
0.25 0.25
0 1 2 3 4 x 0 1 2 3 4 y = 2x
1 1
0.75 0.75
0.50 0.50
0.25 0.25
1/2
-2 -1 0 1 2 y = 2 - 2x 0 1 2 3 4 y=x
1 − x2 , 0 ≤ x ≤ 2
fX (x) =
0 elsewhere
(i) 3
2
− 2y32
(ii) 12 − 2y32
(iii) 12 − 32y
(iv) 21 − y8 ,
Second fundamental theorem of calculus used here, notice cdf of FX (x) is not explicitly calculated.
2y 2y y
(i) 3
2
− 32
(ii) 1
2
+ 32
(iii) 1
2
+ 32
(iv) 1
4
+ y8 ,
(i) 3
2
− 2y
32
(ii) 2√ 1
y
− 14 (iii) √1y − 14 (iv) 2
1
√
y
+ 14 ,
√
Shorten up number of steps, omitted FX ( y).
√
where y = x2 , 0 ≤ x ≤ 2 implies 0 ≤ y ≤ 2, or
(i) 0 ≤ y ≤ 1 (ii) 0 ≤ y ≤ 2 (iii) 0 ≤ y ≤ 3 (iv) 0 ≤ y ≤ 4
√
Although there are two roots, ± y, only the positive root fits in the positive interval 0 ≤ y ≤ 2.
100 Chapter 3. Continuous Random Variables (LECTURE NOTES 5)
3 x6 9 12
-1
inverse cdf: F (y) = P(Y < y)
(b) generates sample point x chosen
-1
at random from desired cdf F (y)
y <- runif(5); y
[1] 0.2189 0.9913 0.5775 0.2846 0.8068
y <- c(0.2189,0.9913,0.5775,0.2846,0.8068)
x <- 3*(1-y)^{-1/3}; x