Module3 LMS
Module3 LMS
Contents
1 Ch 3.1 - Random Variables of the Continuous Type 1
1.1 Cumulative Distribution Function (CDF), Probability Density
Function (PDF) . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1
1.2 MGF and Moments for Continuous Random Variables . . . . . . 5
Asked about the mean and standard deviation of time to 1st accident
Because the event that T1 > t (t > 0)is the same as the event that Xt = 0, for
a Poisson process with rate λ
1
1.0
0.8
0.6
Prob.
0.4
0.2
0.0
0 2 4 6 8 10
0.4
0.2
0.0
0 1 2 3 4
2
1.0
0.8
0.6
CDF
0.4
0.2
0.0
−1 0 1 2 3 4 5
Define for any continuous random variable X the Cumulative Distribution Func-
tion, F , as the function defined for all real values x by
F (x) = P (X ≤ x) (2)
F (x) = P (T1 ≤ x)
(
0, x<0
=
1 − e−λx , x≥0
3
0.1 0.2 0.3 0.4 0.5 0.6
PDF, f(x)
0 1 2 3 4
f (x) = F 0 (x)
(
0, x<0
= (5)
λe−λx , x≥0
4
P(1<T1 ≤ 2) =0.249
P(0<T1 ≤ 1) =0.462
PDF, f(x)
P(0<T1 ≤ 2) =0.711
0 1 2 3 4
x
Mean Z ∞
E(X) = xf (x) dx (7)
−∞
MGF Z ∞
tX
E(e )= etx f (x) dx (8)
−∞
5
Second Moment gives Variance Z ∞
2
E(X ) = x2 f (x) dx (9)
−∞
6
since pdf’s integrate to 1 - this trick will be used frequently
1 = lim P (T ≤ x)
x→∞
Z x
= lim f (x) dx
x→∞ −∞
Z ∞
= f (x) dx
−∞
Z ∞
= λe−λx dx
0
Mean:
1
E(T1 ) = M 0 (0) = = 1.613
0.62
SD:
r
p p 2
V ar(T1 ) = M 00 (0) − (E(T1 ))2 = − (E(T1 ))2
0.622
= 1.613
7
Solution Gamma - MGF and Moments for T4 ctd
CDF F4 can be obtained from the argument used in the example at the end of
Module 2, so for t > 0
In general
MGF of the time, Tn to the nth event of a Poisson process of rate λ is Mn given,
for t < λ by n
λ
Mn (t) = (10)
λ−t
8
Mean & SD √
n n
E(Tn ) = , SD(Tn ) = (11)
λ λ
PDF fn is given by (
0, x<0
f (x) = λn xn−1 e−λx (12)
(n−1)! , x≥0
Proofs
MGF & Moments: We found the MGF for T1 with rate 0.62 in the example -
general λ same. The MGF for Tn now follows, as in the example, by the
fact that the inter-event times Ti − Ti−1 are independent each with the
same exponential pdf as T1 . Differentiate and set to 0 for moments.
CDF WithXt a Poisson process of rate λ,
n−1
X e−λ λi
P (Tn ≤ x) = 1 − P (Xt ≤ n − 1) = 1 −
i=0
i!
PDF Differentiate the CDF with respect to x and get the same telescoping sum
as in the example - see text p. 106
9
Integer α PDFs integrate to one, so comparing with the PDF for Tα , the time
to the nth event in a Poisson process of rate 1,
Γ(α) = (α − 1)! (14)
PDF The probability density function for a general Gamma with shape param-
eter α > 0 and rate parameter λ > 0 is given by
(
0, x<0
f (x) = λα xα−1 e−λx (15)
Γ(α) , x≥0
10
with the 1 in the case α ≤ 1 coming from the fact that the integral from
1 to ∞ is bounded by the mean of an exponential pdf with rate 1 and
the factorial from (16)
PDF& CDF pictures for varying shape and scale parameters are given in Figures
6, 7, 8 and 9. For non-integer shape, the CDF does not have an
easy closed form just like the Gamma function for non-integers.
11
α = 0.25 α=1 α=2 α=3
0.25
0.20
0.15 θ=4
f(x)
0.10
0.05
0.00
0 10 20 30
x
1.00
0.75
F(x)
0.50
0.25
θ=4
0.00
0 10 20 30
x
12
θ = 0.8 θ=1 θ=2 θ=4
0.3
0.2
f(x)
α=4
0.1
0.0
0 10 20 30
x
1.00
0.75
F(x)
0.50
0.25
α=4
0.00
0 10 20 30
x
13
r=2 r=3 r=5 r=8
0.5
0.4
0.3
f(x)
0.2
0.1
0.0
0 10 20 30
x
Mean & SD The mean, µ, and standard deviation, σ, for the Gamma distri-
bution with shape parameter α > 0 and scale parameter θ > 0
are √
µ = αθ, σ = αθ (22)
Chi-Square
The Gamma density with shape being a multiple of 12 , say α = 2r , for some
integer r = 0, 1, 2, · · · and scale 2 is called the Chi- square distribution and
denoted χ2 (r). The pdf is:
(
0, x<0
f (x) = xr/2 −1 e−x/2 (23)
r
2 /2 Γ(r/ )
, x≥0
2
Degrees of Freedom - name given to the parameter r for the Chi-square dis-
tribution. There are many statistical applications of the
Chi-square distribution and in these applications, the name
degrees of freedom is natural. Figures 10 and 11 show the
Chi-square pdf and cdf for varying degrees of freedom
Chi-Square Distribution
MGF For t < 2 the MGF, M , for the χ2 (r) distribution is:
1
M (t) = r (24)
(1 − 2t) /2
Mean & SD The mean, µ, and standard deviation, σ, for the χ2 (r) distribution
are: √
µ = r, σ = 2r (25)
14
r=2 r=3 r=5 r=8
1.00
0.75
F(x)
0.50
0.25
0.00
0 10 20 30
x
Percentiles
Percentiles
Percentiles The 100pth percentile is the pth quantile
Median is the 50th percentile
Example - Chi-Square
Suppose a random variable X has a chi-square distribution with two degrees
of freedom. What is its probability density function? Does it have another
name? What are the mean and median, as well as the 5th, 25th, 75th and 95th
percentiles for the random variable X?
15
1.00
0.75
PDF
0.25
0.00
0 1 π0.75 2 3 4
x
1.00
0.75
CDF
0.25
0.00
0 1 π0.75 2 3 4
x
16
Solution - Chi-Square
PDF is:
0, x<0
f (x) = 2 x
x /2 −1 e− /2
2/ 2
, x≥0
2 2 Γ( /2 )
(
0, x<0
= e− /2
x
2 , x≥0
So
πp = −2 log(1 − p)
Median is −2 log(0.5) = 1.39 - less than the mean because of the skewness
5th 25th,75th and 95th percentiles are −2 log(1 − p) for p = 0.05, 0.25, 0.75, 0.95
so they are
0.013, 0.575, 2.773, 5.991 (respectively)
17
Let f be the density with value c (say) between 2 and 4. Then
Z ∞
1= f (x) dx
−∞
Z 4
= c dx
2
4
= cx
2
= 2c
so c = 1/2 .
Hence (
0, x < 2, x > 4
f (x) = 1
2, 2 ≤ x ≤ 4
Hence
1
σ = √ = 0.5773
3
18
0.5
0.4
0.3
PDF
0.2
0.1
0.0
1 2 3 4 5
x
If 1,000,000 random numbers are generated, the mean and sd of the 1,000,000
numbers would be expected to be close to µ and σ.
How close? - see the subsection on the Central Limit Theorem
x < 2: F (x) = 0
x > 4: F (x) = 1
19
1.00
0.75
CDF
0.50
0.25
0.00
1 2 3 4 5
x
Hence
0,
x<2
x
F (x) = − 1, 2 ≤ x ≤ 4
2
1, x>4
PDF of U is f given by (
0, x < 0, x > 1
f (x) =
1, 0 ≤ x ≤ 1
Figure 16 shows the relationship of events for 2U + 2 and U
20
2u + 2 ≤ x u≤x 2−1
4
y
y = 2u + 2
x
2
0 x 2−1 1
u
x
Figure 16: Event [2U + 2 ≤ x] = [U ≤ 2 − 1]
F (x) = P (2U + 2 ≤ x)
x−2
= P (U ≤ )
2
Z x−2
2
= 1 dy
0
x−2
2
x
= y = −1
0 2
Uniform Distribution
21
µ=3 µ=4 µ=5 µ=6
0.5 σ=1
0.4
0.3
f(x)
0.2
0.1
0.0
0.0 2.5 5.0 7.5 10.0
x
(x − µ)2
1
f (x) = √ exp − (27)
2πσ 2σ 2
22
σ = 0.4 σ = 0.8 σ=1 σ=6
1.00 µ=5
0.75
f(x)
0.50
0.25
0.00
0.0 2.5 5.0 7.5 10.0
x
CDF
CDF cannot be expressed as a finite sum of elementary functions like polyno-
mials or exponentials or logs or trignometric funtions
Showing that the pdf integrates to 1 requires a trick by squaring the integral,
rewriting the square as a double integral and then transforming to
polar co-ordinates
Figures 19 and 20 show normal CDFs with varying µ and σ
Normal probabilities are found from packages like R or Mathematica and his-
torically from tables
23
µ=3 µ=4 µ=5 µ=6
1.00
0.75
F(x)
0.50 σ=1
0.25
0.00
0.0 2.5 5.0 7.5 10.0
x
1.00
0.75
F(x)
0.50 µ=5
0.25
0.00
0.0 2.5 5.0 7.5 10.0
x
24
MGF Ctd
Hence
∞
2µσ 2 t + σ 4 t2 (x − (µ + σ 2 t))2
Z
1
M (t) = exp √ exp − dx
2σ 2 −∞ 2πσ 2σ 2
2µσ 2 t + σ 4 t2
M (t) = exp
2σ 2
σ 2 t2
= exp µt + (28)
2
Derivatives of MGF
First:
σ 2 t2
M 0 (t) = (µ + σ 2 t) exp µt + = (µ + σ 2 t)M (t)
2
σ 2 t2
0 2 2 2
M (t) = (µ + σ t) + σ exp µt +
2
= (µ + σ 2 t)2 + σ 2 M (t)
Moments
Mean
E(X) = (µ + σ 2 × 0)M (0) = µ (29)
Variance
V ar(X) = M 00 (0) − µ2
= (µ + σ 2 × 0)2 + σ 2 M (0) − µ2
= σ2 (30)
SD p
SD(X) = V ar(X) = σ (31)
25
Solution - Normal Calculations
E(X) = 3; SD(X) = 1
Percentiles other than the median - which is 3 by symmetry of the pdf - need
to come from R and here are the commands:
> p <- c(0.05, 0.25, 0.75,0.95)
> qnorm(mean = 3,sd = 1,p)
which give the 5th, 25th, 75th and 95th percentiles as 1.36, 2.33,
3.67 and 4.64 to two dp.
By the same argument as for the change from uniform random numbers on (0,1)
to those on (2,4), Z has a normal distribution
Rules for expectation and variance give
E(Z) = 0; V ar(Z) = 1
So
Z ∼ N (0, 1)
and Z is said to have the standard normal distribution
Z to X
P (X ≤ x) = P (σZ + µ ≤ x)
x−µ
= P (Z ≤ )
σ
ie the number x is turned into statistical units as x−µ
σ and the standard
normal CDF is applied to the number in statistical units
100pth percentile, πp , for Z gives the 100pth percentile for X as σπp + µ
26
0.4 shaded area is 0.68
0.3
Stan. Norm. PDF
0.2
0.1
0.0
−3 −2 −1 0 1 2 −3
x
0.3
Stan. Norm. PDF
0.2
0.1
0.0
−3 −2 −1 0 1 2 −3
x
27
0.4 shaded area is 0.997
0.3
Stan. Norm. PDF
0.2
0.1
0.0
−3 −2 −1 0 1 2 −3
x
28
(D 0.1)2 > 9 D > 0.3
100
y = (D 0.1)2
y
9
0
0.0 0.3 1.0
D
h 2 i
D
Figure 24: Event [D > 0.3] is the same as 0.1 >9
Then p
the distance of the measured location from the true location is D =
D12 + D22 + D32 , so the required probability is
2 2 !
D 0.3
P (D > 0.3) = P >
0.1 0.1
since the two events are the same because the random variable D is non-
negative - see Figure 24
Di , i = 1, 2, 3 be the three independent standardised ran-
Now, letting Zi = 0.1
dom variables,
2
D
= Z12 + Z22 + Z32
0.1
MGF of a sum is the product of the MGF’s and Zi2 ∼ χ21 so the MGF M (t) of
the sum of these three is given by
3
M (t) = (1 − 2t)− /2
29
1.0
0.8
0.6
P(Chisq(3) > x)
0.4
0.2
0.0
0 2 4 6 8
Suppose X1 , X2 , · · · Xn are independent random variables all with the same dis-
tribution having mean µ and standard deviation σ
Pn
Xi
Then letting X̄ be the sample mean - X̄ = i=1
n . From previous results,
σ
E(X̄) = µ; SD(X) = √ (35)
n
30
Example - Conclusions in Opinion Polls
The Australian of 3rd April 2017 reported an opinion poll of 1708 voters
showed that (primary) support for the Government had slipped from last week’s
poll of 37% to 36% this week. The headline was ”Coalition in poll slip after tax
win”. Is this a fair headline assuming the support was actually exactly 37% in
the whole population?s
Note the sample fluctuation explanation is even more plausible taking into ac-
count that the 37% result of the previous week came from another inde-
pendent poll with approximately the same sample size
31