You are on page 1of 17

Continuous Random Variables

COMP 245 STATISTICS


Dr N A Heard
Contents
1 Continuous Random Variables 2
1.1 Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2
1.2 Probability Density Functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3
1.3 Transformations . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5
2 Mean, Variance and Quantiles 6
2.1 Expectation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6
2.2 Variance . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6
2.3 Quantiles . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7
3 Continuous Distributions 8
3.1 Uniform . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8
3.2 Exponential . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9
3.3 Gaussian . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11
1
1 Continuous Random Variables
1.1 Introduction
Denition
Suppose again we have a randomexperiment with sample space S and probability measure
P.
Recall our denition of a random variable as a mapping X : S R from the sample space
S to the real numbers inducing a probability measure P
X
(B) = P{X
1
(B)}, B R.
We dene the random variable X to be (absolutely) continuous if f
X
: R R s.t.
P
X
(B) =
_
xB
f
X
(x)dx, B R, (1)
in which case f
X
is referred to as the probability density function (pdf) of X.
Comments
A connected sequence of comments:
One consequence of this denition is that the probability of any singleton set B = {x}, x
R is zero for a continuous random variable,
P
X
(X = x) = P
X
({x}) = 0.
This in turn implies that any countable set B = {x
1
, x
2
, . . .} R will have zero probabil-
ity measure for a continuous randomvariable, since P
X
(X B) = P
X
(X = x
1
) +P
X
(X =
x
2
) +. . ..
This automatically implies that the range of a continuous random variable will be un-
countable.
This tells us that a random variable cannot be both discrete and continuous.
Examples
The following quantities would typically be modelled with continuous random variables.
They are measurements of time, distance and other phenomena that can, at least in theory, be
determined to an arbitrarily high degree of accuracy.
The height or weight of a randomly chosen individual from a population.
The duration of this lecture.
The volume of fuel consumed by a bus on its route.
The total distance driven by a taxi cab in a day.
Note that there are obvious ways to discretise all of the above examples.
2
1.2 Probability Density Functions
pdf as the derivative of the cdf
From (1), we notice the cumulative distribution function (cdf) for a continuous random
variable X is therefore given by
F
X
(x) =
_
x

f
X
(t)dt, x R,
This expression leads us to a denition of the pdf of a continuous r.v. X for which we
already have the cdf; by the Fundamental Theorem of Calculus we nd the pdf of X to be
given by
f
X
(x) =
d
dx
F
X
(x) or F

X
(x).
Properties of a pdf
Since the pdf is the derivative of the cdf, and because we knowthat a cdf is non-decreasing,
this tells us the pdf will always be non-negative.
So, in the same way as we did for cdfs and discrete pmfs, we have the following checklist
to ensure f
X
is a valid pdf.
pdf:
1. f
X
(x) 0, x R;
2.
_

f
X
(x)dx = 1.
Interval Probabilities
Suppose we are interested in whether continuous a r.v. X lies in an interval (a, b]. From the
denition of a continuous random variable, this is given by
P
X
(a < X b) =
_
b
a
f
X
(x)dx.
That is, the area under the pdf between a and b.
3
x
f
(
x
)
a b
P(a<X<b)
Further Comments:
Besides still being a non-decreasing function satisfying F
X
() = 0, F
X
() = 1, the cdf
F
X
of a continuous random variable X is also (absolutely) continuous.
For a continuous r.v. since x, P(X = x) = 0, F
x
(x) = P(X x) P(X < x).
For small x, f
X
(x)x is approximately the probability that X takes a value in the small
interval, say, [x, x +x).
Since the density (pdf) f
X
(x) is not itself a probability, then unlike the pmf of a discrete
r.v. we do not require f
X
(x) 1.
From (1) it is clear that the pdf of a continuous r.v. X completely characterises its distri-
bution, so we often just specify f
X
.
Example
Suppose we have a continuous random variable X with probability density function
f (x) =
_
cx
2
, 0 < x < 3
0, otherwise
for some unknown constant c.
Questions
1. Determine c.
2. Find the cdf of X.
3. Calculate P(1 < X < 2).
Solutions
1. To nd c: We must have
1 =
_

f (x)dx =
_
3
0
cx
2
dx = c
_
x
3
3
_
3
0
= 9c
c =
1
9
.
4
2. F(x) =
_
_
_
0, x < 0
_
x

f (u)du =
_
x
0
u
2
9
du =
x
3
27
, 0 x 3
1, x > 3.
3. P(1 < X < 2) = F(2) F(1) =
8
27

1
27
=
7
27
0.2593.
1 0 1 2 3 4 5
0
.
0
0
.
2
0
.
4
0
.
6
0
.
8
1
.
0
pdf
x
f
(
x
)
1 0 1 2 3 4 5
0
.
0
0
.
2
0
.
4
0
.
6
0
.
8
1
.
0
cdf
x
F
(
x
)
1.3 Transformations
Transforming random variables
Suppose we have a continuous random variable X and wish to consider the transformed
random variable Y = g(X) for some function g : R R, s.t. g is continuous and strictly
monotonic (so g
1
exists).
Suppose g is monotonic increasing. Then for y R, Y y X g
1
(y). So
F
Y
(y) = P
Y
(Y y) = P
X
(X g
1
(y)) = F
X
(g
1
(y))
By the chain rule of differentiation,
f
Y
(y) = F

Y
(y) = f
X
{g
1
(y)}g
1

(y)
Note g
1

(y) =
d
dy
g
1
(y) is positive since we assumed g was increasing.
If we had g monotonic decreasing, Y y X g
1
(y) and
F
Y
(y) = P
X
(X g
1
(y)) = 1 F
X
(g
1
(y)).
So by comparison with before, we would have
f
Y
(y) = F

Y
(y) = f
X
{g
1
(y)}g
1

(y)
with g
1

(y) always negative.


So overall, for Y = g(X) we have
f
Y
(y) = f
X
{g
1
(y)}|g
1

(y)|. (2)
5
2 Mean, Variance and Quantiles
2.1 Expectation
E(X)
For a continuous random variable X we dene the mean or expectation of X,

X
or E
X
(X) =
_

x f
X
(x)dx.
More generally, for a function of interest of the random variable g : R R we have
E
X
{g(X)} =
_

g(x) f
X
(x)dx.
Linearity of Expectation
Clearly, for continuous random variables we again have linearity of expectation
E(aX + b) = aE(X) + b, a, b R,
and that for two functions g, h : R R, we have additivity of expectation
E{g(X) + h(X)} = E{g(X)} +E{h(X)}.
2.2 Variance
Var(X)
The variance of a continuous random variable X is given by

2
X
or Var
X
(X) = E{(X
X
)
2
} =
_

(x
X
)
2
f
X
(x)dx.
and again it is easy to show that
Var
X
(X) =
_

x
2
f
X
(x)dx
2
X
= E(X
2
) {E(X)}
2
.
For a linear transformation aX + b we again have Var(aX + b) = a
2
Var(X), a, b
R.
6
2.3 Quantiles
Q
X
()
Recall we dened the lower and upper quartiles and median of a sample of data as points
(,,)-way through the ordered sample.
For [0, 1] and a continuous random variable X we dene the -quantile of X, Q
X
(),
as
Q
X
() = min
qR
{q : F
X
(q) = }.
If F
X
is invertible then
Q
X
() = F
1
X
().
In particular the median of a randomvariable X is Q
X
(0.5). That is, the median is a solution
to the equation F
X
(x) =
1
2
.
Example (continued)
Again suppose we have a continuous random variable X with probability density function
given by
f (x) =
_
x
2
/9, 0 < x < 3
0, otherwise.
Questions
1. Calculate E(X).
2. Calculate Var(X).
3. Calculate the median of X.
Solutions
1. E(X) =
_

x f (x)dx =
_
3
0
x.
x
2
9
dx =
x
4
36

3
0
=
3
4
36
= 2.25.
2. E(X
2
) =
_

x
2
f (x)dx =
_
3
0
x
2
.
x
2
9
dx =
x
5
45

3
0
=
3
5
45
= 5.4.
So Var(X) = E(X
2
) {E(X)}
2
= 5.4 2.25
2
= 0.3375.
3. From earlier, F(x) =
x
3
27
, for 0 < x < 3.
Setting F(x) =
1
2
and solving, we get
x
3
27
=
1
2
x =
3
_
27
2
=
3
3

2
2.3811 for the
median.
7
3 Continuous Distributions
3.1 Uniform
U(a, b)
Suppose X is a continuous random variable with probability density function
f (x) =
_
1
ba
, a < x < b
0, otherwise,
and hence corresponding cumulative distribution function
F(x) =
_
_
_
0, x a
xa
ba
, a < x < b
1, x b.
Then X is said to follow a uniform distribution on the interval (a, b) and we write X
U(a, b).
Example: U(0,1)
-
6
1
0 1 x
f (x)
-
6

1
0 1 x
F(x)
Notice from the cdf that the quantiles of U(0,1) are the special case where Q() = .
Relationship between U(a, b) and U(0,1)
Suppose X U(0, 1), so F
X
(x) = x, 0 x 1. For a < b R, if Y = a + (b a)X then
Y U(a, b).
0 1
X
a
b
Y
.
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
-
Proof:
We rst observe that for any y (a, b), Y y a + (b a)X y X
y a
b a
.
Fromthis we nd Y U(a, b), since F
Y
(y) = P(Y y) = P
_
X
y a
b a
_
= F
X
_
y a
b a
_
=
y a
b a
.
8
Mean and Variance of U(a, b)
To nd the mean of X U(a, b),
E(X) =
_

x f (x)dx =
_
b
a
x.
1
b a
dx =
_
x
2
2(b a)
_
b
a
=
b
2
a
2
2(b a)
=
(b a)(b + a)
2(b a)
=
a + b
2
.
Similarly we get Var(X) = E(X
2
) E(X)
2
=
(ba)
2
12
, so
=
a + b
2
,
2
=
(b a)
2
12
.
3.2 Exponential
Exp()
Suppose now X is a random variable taking value on R
+
= [0, ) with pdf
f (x) = e
x
, x 0,
for some > 0.
Then X is said to follow an exponential distribution with rate parameter and we write
X Exp().
Straightforward integration between 0 and x leads to the cdf,
F(x) = 1 e
x
, x 0.
The mean and variance are given by
=
1

,
2
=
1

2
.
Example: Exp(1), Exp(0.5) & Exp(0.2) pdfs
0 2 4 6 8 10
0
.
0
0
.
2
0
.
4
0
.
6
0
.
8
1
.
0
x
f
(
x
)
= 1
= 0.5
= 0.2
9
Example: Exp(0.2), Exp(0.5) & Exp(1) cdfs
0 2 4 6 8 10
0
.
0
0
.
2
0
.
4
0
.
6
0
.
8
1
.
0
x
F
(
x
)
Lack of Memory Property
First notice that from the exponential distribution cdf equation we have P(X > x) = e
x
.
An important (and not always desirable) characteristic of the exponential distribution is
the so called lack of memory property.
For x, s > 0, consider the conditional probability P(X > x + s|X > s) of the additional
magnitude of an exponentially distributed randomvariable given we already knowit is greater
than s.
Well
P(X > x + s|X > s) =
P(X > x + s)
P(X > s)
,
which, when X Exp(), gives
P(X > x + s|X > s) =
e
(x+s)
e
s
= e
x
,
again an exponential distribution with parameter .
So if we think of the exponential variable as the time to an event, then knowledge that we
have waited time s for the event tells us nothing about how much longer we will have to wait
- the process has no memory.
Examples
Exponential random variables are often used to model the time until occurrence of a ran-
dom event where there is an assumed constant risk () of the event happening over time, and
so are frequently used as a simplest model, for example, in reliability analysis. So examples
include:
the time to failure of a component in a system;
the time until we nd the next mistake on my slides;
the distance we travel along a road until we nd the next pothole;
the time until the next jobs arrives at a database server;
10
Link with Poisson Distribution
Notice the duality between some of the exponential r.v. examples and those we saw for a
Poisson distribution. In each case, number of events has been replaced with time between
events.
Claim:
If events in a random process occur according to a Poisson distribution with rate then the
time between events has an exponential distribution with rate parameter .
Proof:
Suppose we have some random event process such that x > 0, the number of events
occurring in [0, x], N
x
, follows a Poisson distribution with rate parameter , so N
x
Poi(x).
Such a process is known as an homogeneous Poisson process. Let X be the time until the rst
event of this process arrives.
Then we notice that
P(X > x) P(N
x
= 0)
=
(x)
0
e
x
0!
= e
x
.
and hence X Exp(). The same argument applies for all subsequent inter-arrival times.
3.3 Gaussian
N(,
2
)
Suppose X is a random variable taking value on R with pdf
f (x) =
1

2
exp
_

(x )
2
2
2
_
,
for some R, > 0.
Then X is said to follow a Gaussian or normal distribution with mean and variance
2
,
and we write X N(,
2
).
The cdf of X N(,
2
) is not analytically tractable for any (, ), so we can only write
F(x) =
1

2
_
x

exp
_

(t )
2
2
2
_
dt.
11
Example: N(0,1), N(2,1) & N(0,4) pdfs
4 2 0 2 4 6
0
.
0
0
.
1
0
.
2
0
.
3
0
.
4
x
f
(
x
)
N(0,1) N(2,1)
N(0,4)
Example: N(0,1), N(2,1) & N(0,4) cdfs
4 2 0 2 4 6
0
.
0
0
.
2
0
.
4
0
.
6
0
.
8
1
.
0
x
F
(
x
)
N(0, 1)
Setting = 0, = 1 and Z N(0, 1) gives the special case of the standard normal, with
simplied density
f (z) (z) =
1

2
e

z
2
2
.
Again for the cdf, we can only write
F(z) (z) =
1

2
_
z

t
2
2
dt.
Statistical Tables
Since the cdf, and therefore any probabilities, associated with a normal distribution are not
analytically available, numerical integration procedures are used to nd approximate proba-
bilities.
12
In particular, statistical tables contain values of the standard normal cdf (z) for a range of
values z R, and the quantiles
1
() for a range of values (0, 1). Linear interpolation is
used for approximation between the tabulated values.
But why just tabulate N(0, 1)? We will now see how all normal distribution probabilities
can be related back to probabilities from a standard normal distribution.
Linear Transformations of Normal Random Variables
Suppose we have X N(,
2
). Then it is also true that for any constants a, b R, the
linear combination aX + b also follows a normal distribution. More precisely,
X N(,
2
) aX + b N(a + b, a
2

2
), a, b R.
(Note that the mean and variance parameters of this transformed distribution follow from the
general results for expectation and variance of any random variable under linear transforma-
tion.)
In particular, this allows us to standardise any normal r.v.,
X N(,
2
)
X

N(0, 1).
Standardising Normal Random Variables
So if X N(,
2
) and we set Z =
X

, then since > 0 we can rst observe that for


any x R,
X x
X

Z
x

.
Therefore we can write the cdf of X in terms of ,
F
X
(x) = P(X x) = P
_
Z
x

_
=
_
x

_
.
Table of
z (z) z (z) z (z) z (z)
0 .5 0.9 .816 1.8 .964 2.8 .997
.1 .540 1.0 .841 1.9 .971 3.0 .998
.2 .579 1.1 .864 2.0 .977 3.5 .9998
.3 .618 1.2 .885 2.1 .982 1.282 .9
.4 .655 1.3 .903 2.2 .986 1.645 .95
.5 .691 1.4 .919 2.3 .989 1.96 .975
.6 .726 1.5 .933 2.4 .992 2.326 .99
.7 .758 1.6 .945 2.5 .994 2.576 .995
.8 .788 1.7 .955 2.6 .995 3.09 .999
13
Using Table of
First of all notice that (z) has been tabulated for z > 0.
This is because the standard normal pdf is symmetric about 0, so (z) = (z). For the
cdf , this means
(z) = 1 (z).
So for example, (1.2) = 1 (1.2) 1 0.885 = 0.115.
Similarly, if Z N(0, 1) and we want P(Z > z), then for example P(Z > 1.5) = 1 P(Z
1.5) = 1 (1.5).
Important Quantiles of N(0, 1)
We will often have cause to use the 97.5%and 99.5%quantiles of N(0, 1), given by
1
(0.975)
and
1
(0.995).
(1.96) 97.5%.
So with 95% probability an N(0, 1) r.v. will lie in [1.96, 1.96] ( [2, 2]).
(2.58) = 99.5%.
So with 99% probability an N(0, 1) r.v. will lie in [2.58, 2.58].
More generally, for (0, 1) and dening z
1/2
to be the (1 /2) quantile of N(0, 1), if
Z N(0, 1) then
P
Z
(Z [z
1/2
, z
1/2
]) = 1 .
More generally still, if X N(,
2
), then
P
X
(X [ z
1/2
, +z
1/2
]) = 1 ,
and hence [ z
1/2
, + z
1/2
] gives a (1 ) probability region for X centred around
.
This can be rewritten as
P
X
(|X | z
1/2
) = 1 .
Example
An analogue signal received at a detector (measured in microvolts) may be modelled as a
Gaussian random variable X N(200, 256).
1. What is the probability that the signal will exceed 240V?
2. What is the probability that the signal is larger than 240V given that it is greater than
210V?
Solutions:
1. P(X > 240) = 1 P(X 240) = 1
_
240 200

256
_
= 1 (2.5) 0.00621.
14
2. P(X > 240|X > 210) =
P(X > 240)
P(X > 210)
=
1
_
240200

256
_
1
_
210200

256
_ 0.02335.
The Central Limit Theorem
Let X
1
, X
2
, . . . , X
n
be n independent and identically distributed (i.i.d.) random variables
from any probability distribution, each with mean and variance
2
.
Frombefore we knowE
_
n

i=1
X
i
_
= n,Var
_
n

i=1
X
i
_
= n
2
. First notice E
_
n

i=1
X
i
n
_
=
0, Var
_
n

i=1
X
i
n
_
= n
2
. Dividing by

n, E
_

n
i=1
X
i
n

n
_
= 0, Var
_

n
i=1
X
i
n

n
_
=
1.
But we can now present the following, astonishing result.
lim
n

n
i=1
X
i
n

n
.
This can also be written as
lim
n

X
/

n
,
where

X =

n
i=1
X
i
n
.
Or nally, for large n we have approximately

X N
_
,

2
n
_
,
or
n

i=1
X
i
N
_
n, n
2
_
.
We note here that although all these approximate distributional results hold irrespective
of the distribution of the {X
i
}, in the special case where X
i
N(,
2
) these distributional
results are, in fact, exact. This is because the sum of independent normally distributed random
variables is also normally distributed.
Example
Consider the most simple example, that X
1
, X
2
, . . . are i.i.d. Bernoulli(p) discrete random
variables taking value 0 or 1.
Then the {X
i
} each have mean = p and variance
2
= p(1 p).
By denition, we know that for any n,
n

i=1
X
i
Binomial(n, p).
15
But now, by the Central Limit Theorem (CLT), we also have for large n that approximately
n

i=1
X
i
N
_
n, n
2
_
N(np, np(1 p)).
So for large n
Binomial(n, p) N(np, np(1 p)).
Notice that the LHS is a discrete distribution, and the RHS is a continuous distribution.
Binomial(10,) pmf & N(5,2.5) pdf
0 2 4 6 8 10
0
.
0
0
0
.
0
5
0
.
1
0
0
.
1
5
0
.
2
0
0
.
2
5
x
p
(
x
)
Binomial(10,0.5)
0 2 4 6 8 10
0
.
0
0
0
.
0
5
0
.
1
0
0
.
1
5
0
.
2
0
0
.
2
5
x
f
(
x
)
N(5,2.5)
Binomial(100,) pmf & N(50,25) pdf
20 30 40 50 60 70 80
0
.
0
0
0
.
0
2
0
.
0
4
0
.
0
6
0
.
0
8
x
p
(
x
)
Binomial(100,0.5)
20 30 40 50 60 70 80
0
.
0
0
0
.
0
2
0
.
0
4
0
.
0
6
0
.
0
8
x
f
(
x
)
N(50,25)
16
Binomial(1000,) pmf & N(500,250) pdf
400 450 500 550 600
0
.
0
0
0
0
.
0
0
5
0
.
0
1
0
0
.
0
1
5
0
.
0
2
0
0
.
0
2
5
x
p
(
x
)
Binomial(1000,0.5)
400 450 500 550 600
0
.
0
0
0
0
.
0
0
5
0
.
0
1
0
0
.
0
1
5
0
.
0
2
0
0
.
0
2
5
x
f
(
x
)
N(500,250)
So suppose X was the number of heads found on 1000 tosses of a fair coin, and we were
interested in P(X 490).
Using the binomial distribution pmf, we would need to calculate P(X 490) = p
X
(0) +
p
X
(1) + p
X
(2) +. . . + p
X
(490) (!) ( 0.27).
However, using the CLT we have approximately X N(500, 250) and so P(X 490)

_
490 500

250
_
= (0.632) = 1 (0.632) 0.26.
Log-Normal Distribution
Suppose X N(,
2
), and consider the transformation Y = e
X
.
Then if g(x) = e
x
, g
1
(y) = log(y) and g
1

(y) =
1
y
.
Then by (2) we have
f
Y
(y) =
1
y

2
exp
_

{log(y) }
2
2
2
_
, y > 0,
and we say Y follows a log-normal distribution.
Example: LN(0,1), LN(2,1) & LN(0,4) pdfs
0 2 4 6 8 10
0
.
0
0
.
2
0
.
4
0
.
6
0
.
8
1
.
0
1
.
2
x
f
(
x
)
LN(0,1)
LN(2,1)
LN(0,4)
17

You might also like