Chapter 4 RANDOM
VARIABLES
Experiments whose outcomes are
numbers
EXAMPLE:
Select items at random from a batch of size
N until the first defective item is found.
Record the number of non-defective items.
Sample Space: S = {0, 1, 2, . . . , N }
The result from the experiment becomes a
variable; that is, a quantity taking different
values on different occasions. Because the
experiment involves selection at random, we
call it a random variable.
Abbreviation: rv
Notation: capital letter, often X.
REMINDER:
The set of possible values that a random
variable (rv) X can take is called the range
of X.
DEFINITION:
A rv X is said to be discrete if its range
consists of a finite or countable number of
values.
Examples: based on tossing a coin repeatedly
No. of H in 1st 5 tosses: {0, 1, 2, . . . ., 5}
No. of T before first H: {0, 1, 2, . . . .}
Note: although the definition of a discrete rv
allows it to take any finite or countable set of
values, the values are in practice almost
always integers.
DEFINITION:
The Probability Function of a discrete
random variable X is the function p(x)
satisfying
p(x) = Pr(X = x)
for all values x in the range of X.
Abbreviation: pf
Notation: p(x) or pX (x). We use the pX (x)
form when we need to make the identity of
the rv clear.
Terminology: The pf is sometimes given the
alternative name of probability mass function
(pmf).
Properties of a pf
If pX (x) is the pf of a rv X, then
• pX (x) ≥ 0, for all x in the range of X.
•
P
pX (x) = 1, where the sum is taken
over the range of X.
Informal ‘definition’ of a distribution:
The pf of a discrete rv describes how the
total probability, 1, is split, or distributed,
between the various possible values of X.
This ‘split’ or pattern is known as the
distribution of the rv.
Note: The pf is not the only way of
describing the distribution of a discrete rv.
Any 1–1 function of the pf will do.
EXAMPLE: Discrete Uniform Distribution
The rv X is equally likely to take each integer
value in the range 1, 2, . . . , n.
Probability function:
1 , x = 1, 2, . . . , n ,
pX (x) = n
0 elsewhere.
Cumulative distribution function:
0, x < 1,
[x]
FX (x) = n , 1 ≤ x ≤ n,
1, x ≥ n,
where [x] is the integer part of x.
Note: The cdf is defined for all values of x,
not just the ones in the range of X.
1 for all values
For this distribution, the cdf is n
of x in the range 1 ≤ x < 2, then jumps to n 2,
and so on.
• It satisfies FX (−∞) = 0 ,
• It satisfies FX (∞) = 1 .
DEFINITION: A random variable is said to
be continuous if its cdf is a continuous
function (see later).
This is an important case, which occurs
frequently in practice.
EXAMPLE: The Exponential Distribution
Consider the rv Y with cdf
0, y < 0,
FY (y) =
1 − e−y , y ≥ 0 .
This meets all the requirements above, and is
not a step function.
The cdf is a continuous function.
Mean and Variance
The pf gives a complete description of the
behaviour of a (discrete) random variable. In
practice we often want a more concise
description of its behaviour.
DEFINITION: The mean or expectation of
a discrete rv X, E(X), is defined as
X
E(X) = x Pr(X = x).
x
X
Note: Here (and later) the notation means
x
the sum over all values x in the range of X.
The expectation E(X) is a weighted average
of these values. The weights always sum to 1.
Extension: The concept of expectation can
be generalised; we can define the expectation
of any function of a rv. Thus we obtain, for a
function g(·) of a discrete rv X,
X
E{g(X)} = g(x) Pr(X = x) .
x
Measures of dispersion
There are many possible measures. We look
briefly at three plausible ones.
A. ‘Mean difference’: E{X − E(X)}.
Attractive superficially, but no use.
B. Mean absolute difference: E{|X − E(X)|}.
Hard to manipulate mathematically.
C. Variance: E{X − E(X)}2.
The most frequently-used measure.
Notation for variance: V(X) or Var(X).
That is: V(X) = Var(X) = E{X − E(X)}2.
EXAMPLE:
We find the mean and variance for the
random variable X with pf as in the table:
x 1 2 3 4 5
p(x) = Pr(X = x) 0.1 0.1 0.2 0.4 0.2
P
E(X) = x x Pr(X = x), so
E(X) = (1 × 0.1) + (2 × 0.1) + (3 × 0.2)
+(4 × 0.4) + (5 × 0.2) = 3.5.
Var(X) = E(X 2) − {E(X)}2, and
E(X 2) = (12 × 0.1) + (22 × 0.1) + (32 × 0.2)
+(42 × 0.4) + (52 × 0.2) = 13.7 ,
so Var(X) = 13.7 − (3.5)2 = 1.45.
√
Standard deviation of X: 1.45, or 1.20.
CONTINUOUS RANDOM
VARIABLES
Introduction
Reminder: a rv is said to be continuous if its
cdf is a continuous function.
If the function FX (x) = Pr(X ≤ x) of x is
continuous, what is Pr(X = x)?
Pr(X = x) = Pr(X ≤ x) − Pr(X < x)
= 0, by continuity
A continuous random variable does not
possess a probability function.
Probability cannot be assigned to individual
values of x; instead, probability is assigned to
intervals. [Strictly, half-open intervals]
Example: We gave earlier an example of a
continuous cdf:
0, y < 0,
FY (y) =
1 − e−y , y ≥ 0 .
This is the cdf of what is termed the
exponential distribution with mean 1.
For the case of that distribution, we can find
Pr(Y ≤ 1) = FY (1) = 1 − e−1 = 0.6322
Pr(2 ≤ Y ≤ 3) = FY (3) − FY (2)
= (1 − e−3) − (1 − e−2) = 0.0856
Pr(Y ≥ 2.5) = FY (∞) − FY (2.5)
= 1 − (1 − e−2.5) = 0.0821
The probability density function
Alternative names: pdf,
density function,
density.
Notation for pdf: fX (x)
Recall: The cdf of X is denoted by FX (x)
d FX (x)
Relationship: fX (x) =
dx
Care needed: Make sure f and F cannot be
confused!
Interpretation
• When multiplied by a small number h,
the pdf gives, approximately, the probability
that X lies in a small interval, length h, close
to x.
• If, for example, fX (4) = 2 fX (7), then
X occurs near 4 twice as often as near 7.
Mean and Variance
Reminder: for a discrete rv, the formulae for
mean and variance are based on the
probability function Pr(X = x). We need to
adapt these formulae for use with continuous
random variables.
DEFINITION:
For a continuous rv X with pdf fX (x), the
expectation of a function g(x) is defined as
Z ∞
E{g(X)} = g(x) fX (x) dx
−∞
Hence, for the mean:
Z ∞
E(X) = x fX (x) dx
−∞
Compare this with the equivalent definition
for a discrete random variable:
X X
E(X) = x Pr(X = x) , or E(X) = xpX (x) .
x x
The Uniform Distribution
Distribution of a rv which is equally likely to
take any value in its range, say a to b (b > a).
The pdf is constant:
6
fX (x)
1
b−a
a b
Because fX (x) is constant over [a, b] and
Z ∞ Z b
fX (x) dx = fX (x) dx = 1,
−∞ a
1 , a < x < b,
b−a
fX (x) =
0
elsewhere.
Uniform Distribution: Mean and Variance
Z b
1
E(X) = µ = x dx
a b−a
= 1
2 (a + b).
Var(X) = σ 2 = E(X 2) − µ2
(a + b)2
Z b
1
= x2 dx −
a b−a 4
1
= (b − a)2.
12
For example, if a random variable is uniformly
distributed on the range (20,140), then
a = 20 and b = 140, so the mean is 80. The
variance is 1200, so the standard deviation is
34.64.
Properties of the exponential distribution
The distribution has pdf
λe−λx, x ≥ 0 ,
fX (x) =
0, x < 0.
and its cdf is given by
Z x
FX (x) = λe−λy dy
0
= 1 − e−λx, x > 0.
Mean and Variance
Z ∞
−λx 1
E(X) = x λe dx = .
0 λ
For the variance, we use integration by parts
to obtain
Z ∞
2
E(X 2) = x2 λe−λx dx = 2 .
0 λ
Hence Var(X) = E(X 2) − {E(X)}2
2
2 1 1
= 2− = 2.
λ λ λ
Cumulative distribution function
If X ∼ N(µ, σ 2), the cdf of X is the integral:
2
− (x−µ)
Z x
1
FX (x) = √ e 2σ 2 dx.
−∞ σ 2π
This cannot be evaluated analytically.
Numerical integration is necessary: extensive
tables are available.
The Standardised Normal Distribution
The Normal distribution with mean 0 and
variance 1 is known as the standardised
Normal distribution (SND). We usually
denote a random variable with this
distribution by Z. Hence
Z ∼ N(0, 1).
Special notation φ(z) is used for the pdf of
N(0, 1). We write
1 − 1 z2
φ(z) = √ e 2 , −∞ < z < ∞.
2π
The cdf of Z is denoted by Φ(z). We write
Z z
Φ(z) = φ(x) dx
−∞
1 − 1 x2
Z z
= √ e 2 dx
−∞ 2π
Tables of Φ(z) are available in statistical
textbooks and computer programs.