course 02402 introduction to statistics lecture 3: random
TRANSCRIPT
![Page 1: Course 02402 Introduction to Statistics Lecture 3: Random](https://reader030.vdocuments.us/reader030/viewer/2022021408/6209b0641ea8160b220fa197/html5/thumbnails/1.jpg)
Course 02402 Introduction to Statistics
Lecture 3: Random variables and continuous distributions
DTU ComputeTechnical University of Denmark2800 Lyngby – Denmark
Andreas Baum (DTU Compute) Introduction to Statistics Spring 2022 1 / 49
![Page 2: Course 02402 Introduction to Statistics Lecture 3: Random](https://reader030.vdocuments.us/reader030/viewer/2022021408/6209b0641ea8160b220fa197/html5/thumbnails/2.jpg)
Overview
1 Continuous random variables and distributionsDensity and distribution functionsMean, variance, and covariance
2 Specific continuous distributionsThe uniform distributionThe normal distributionThe log-normal distributionThe exponential distribution
3 Calculation rules for random variables
Andreas Baum (DTU Compute) Introduction to Statistics Spring 2022 2 / 49
![Page 3: Course 02402 Introduction to Statistics Lecture 3: Random](https://reader030.vdocuments.us/reader030/viewer/2022021408/6209b0641ea8160b220fa197/html5/thumbnails/3.jpg)
Continuous random variables and distributions
Overview
1 Continuous random variables and distributionsDensity and distribution functionsMean, variance, and covariance
2 Specific continuous distributionsThe uniform distributionThe normal distributionThe log-normal distributionThe exponential distribution
3 Calculation rules for random variables
Andreas Baum (DTU Compute) Introduction to Statistics Spring 2022 3 / 49
![Page 4: Course 02402 Introduction to Statistics Lecture 3: Random](https://reader030.vdocuments.us/reader030/viewer/2022021408/6209b0641ea8160b220fa197/html5/thumbnails/4.jpg)
Continuous random variables and distributions Density and distribution functions
The density function, Definition 2.32
The density function (probability density function, pdf) for a random variable is
denoted by f (x).
The density function says something about the frequency of the outcome x for the
random variable X.
The density function for a continuous random variable does not correspond directly
to a probability. In fact, f (x) 6= P(X = x) and P(X = x) = 0 for all x.
The density function f (x) for the distribution of a continuous random variable
satisfies that
f (x)≥ 0 for all x and
∫∞
−∞
f (x)dx = 1 .
Andreas Baum (DTU Compute) Introduction to Statistics Spring 2022 4 / 49
![Page 5: Course 02402 Introduction to Statistics Lecture 3: Random](https://reader030.vdocuments.us/reader030/viewer/2022021408/6209b0641ea8160b220fa197/html5/thumbnails/5.jpg)
Continuous random variables and distributions Density and distribution functions
The density function, Definition 2.32
The density function (probability density function, pdf) for a random variable is
denoted by f (x).
The density function says something about the frequency of the outcome x for the
random variable X.
The density function for a continuous random variable does not correspond directly
to a probability. In fact, f (x) 6= P(X = x) and P(X = x) = 0 for all x.
The density function f (x) for the distribution of a continuous random variable
satisfies that
f (x)≥ 0 for all x and
∫∞
−∞
f (x)dx = 1 .
Andreas Baum (DTU Compute) Introduction to Statistics Spring 2022 4 / 49
![Page 6: Course 02402 Introduction to Statistics Lecture 3: Random](https://reader030.vdocuments.us/reader030/viewer/2022021408/6209b0641ea8160b220fa197/html5/thumbnails/6.jpg)
Continuous random variables and distributions Density and distribution functions
The density function, Definition 2.32
The density function (probability density function, pdf) for a random variable is
denoted by f (x).
The density function says something about the frequency of the outcome x for the
random variable X.
The density function for a continuous random variable does not correspond directly
to a probability. In fact, f (x) 6= P(X = x) and P(X = x) = 0 for all x.
The density function f (x) for the distribution of a continuous random variable
satisfies that
f (x)≥ 0 for all x and
∫∞
−∞
f (x)dx = 1 .
Andreas Baum (DTU Compute) Introduction to Statistics Spring 2022 4 / 49
![Page 7: Course 02402 Introduction to Statistics Lecture 3: Random](https://reader030.vdocuments.us/reader030/viewer/2022021408/6209b0641ea8160b220fa197/html5/thumbnails/7.jpg)
Continuous random variables and distributions Density and distribution functions
The density function, Definition 2.32
The density function (probability density function, pdf) for a random variable is
denoted by f (x).
The density function says something about the frequency of the outcome x for the
random variable X.
The density function for a continuous random variable does not correspond directly
to a probability. In fact, f (x) 6= P(X = x) and P(X = x) = 0 for all x.
The density function f (x) for the distribution of a continuous random variable
satisfies that
f (x)≥ 0 for all x and
∫∞
−∞
f (x)dx = 1 .
Andreas Baum (DTU Compute) Introduction to Statistics Spring 2022 4 / 49
![Page 8: Course 02402 Introduction to Statistics Lecture 3: Random](https://reader030.vdocuments.us/reader030/viewer/2022021408/6209b0641ea8160b220fa197/html5/thumbnails/8.jpg)
Continuous random variables and distributions Density and distribution functions
The density function
x
f(x
)
P (a < X b)
a b
Andreas Baum (DTU Compute) Introduction to Statistics Spring 2022 5 / 49
![Page 9: Course 02402 Introduction to Statistics Lecture 3: Random](https://reader030.vdocuments.us/reader030/viewer/2022021408/6209b0641ea8160b220fa197/html5/thumbnails/9.jpg)
Continuous random variables and distributions Density and distribution functions
The distribution function, Definition 2.33
The distribution function (cumulative density function, cdf) for a continuous
random variable is denoted by F(x).
The distribution function is defined by
F(x) = P(X ≤ x) =∫ x
−∞
f (t)dt .
Note that as a consequence of this definition,
f (x) = F′(x) .
It’s particularly useful to note that
P(a < X ≤ b) = F(b)−F(a) =∫ b
af (x)dx .
Andreas Baum (DTU Compute) Introduction to Statistics Spring 2022 6 / 49
![Page 10: Course 02402 Introduction to Statistics Lecture 3: Random](https://reader030.vdocuments.us/reader030/viewer/2022021408/6209b0641ea8160b220fa197/html5/thumbnails/10.jpg)
Continuous random variables and distributions Density and distribution functions
The distribution function, Definition 2.33
The distribution function (cumulative density function, cdf) for a continuous
random variable is denoted by F(x).
The distribution function is defined by
F(x) = P(X ≤ x) =∫ x
−∞
f (t)dt .
Note that as a consequence of this definition,
f (x) = F′(x) .
It’s particularly useful to note that
P(a < X ≤ b) = F(b)−F(a) =∫ b
af (x)dx .
Andreas Baum (DTU Compute) Introduction to Statistics Spring 2022 6 / 49
![Page 11: Course 02402 Introduction to Statistics Lecture 3: Random](https://reader030.vdocuments.us/reader030/viewer/2022021408/6209b0641ea8160b220fa197/html5/thumbnails/11.jpg)
Continuous random variables and distributions Density and distribution functions
The distribution function, Definition 2.33
The distribution function (cumulative density function, cdf) for a continuous
random variable is denoted by F(x).
The distribution function is defined by
F(x) = P(X ≤ x) =∫ x
−∞
f (t)dt .
Note that as a consequence of this definition,
f (x) = F′(x) .
It’s particularly useful to note that
P(a < X ≤ b) = F(b)−F(a) =∫ b
af (x)dx .
Andreas Baum (DTU Compute) Introduction to Statistics Spring 2022 6 / 49
![Page 12: Course 02402 Introduction to Statistics Lecture 3: Random](https://reader030.vdocuments.us/reader030/viewer/2022021408/6209b0641ea8160b220fa197/html5/thumbnails/12.jpg)
Continuous random variables and distributions Density and distribution functions
The distribution function, Definition 2.33
The distribution function (cumulative density function, cdf) for a continuous
random variable is denoted by F(x).
The distribution function is defined by
F(x) = P(X ≤ x) =∫ x
−∞
f (t)dt .
Note that as a consequence of this definition,
f (x) = F′(x) .
It’s particularly useful to note that
P(a < X ≤ b) = F(b)−F(a) =∫ b
af (x)dx .
Andreas Baum (DTU Compute) Introduction to Statistics Spring 2022 6 / 49
![Page 13: Course 02402 Introduction to Statistics Lecture 3: Random](https://reader030.vdocuments.us/reader030/viewer/2022021408/6209b0641ea8160b220fa197/html5/thumbnails/13.jpg)
Continuous random variables and distributions Density and distribution functions
The distribution function
x
F(x
)
P(a
<X
b)
=F
(b)�
F(a
)
a b
Andreas Baum (DTU Compute) Introduction to Statistics Spring 2022 7 / 49
![Page 14: Course 02402 Introduction to Statistics Lecture 3: Random](https://reader030.vdocuments.us/reader030/viewer/2022021408/6209b0641ea8160b220fa197/html5/thumbnails/14.jpg)
Continuous random variables and distributions Density and distribution functions
The empirical cumulative distribution function (ecdf)
# Empirical cdf for sample of height data from Chapter 1
x <- c(168, 161, 167, 179, 184, 166, 198, 187, 191, 179)
plot(ecdf(x), verticals = TRUE, main = "")
# 'True cdf' for normal distribution (with sample mean and variance)
xp <- seq(0.9*min(x), 1.1*max(x), length = 100)
lines(xp, pnorm(xp, mean(x), sd(x)), col = 2)
160 170 180 190 200
0.0
0.2
0.4
0.6
0.8
1.0
x
Fn(
x)
●
●
●
●
●
●
●
●
●
Andreas Baum (DTU Compute) Introduction to Statistics Spring 2022 8 / 49
![Page 15: Course 02402 Introduction to Statistics Lecture 3: Random](https://reader030.vdocuments.us/reader030/viewer/2022021408/6209b0641ea8160b220fa197/html5/thumbnails/15.jpg)
Continuous random variables and distributions Mean, variance, and covariance
Mean, continuous random variable, Definition 2.34
The mean/expected value of a continuous random variable:
µ =∫
∞
−∞
x f (x)dx
Compare with the mean of a discrete random variable:
µ = ∑all x
x f (x)
Andreas Baum (DTU Compute) Introduction to Statistics Spring 2022 9 / 49
![Page 16: Course 02402 Introduction to Statistics Lecture 3: Random](https://reader030.vdocuments.us/reader030/viewer/2022021408/6209b0641ea8160b220fa197/html5/thumbnails/16.jpg)
Continuous random variables and distributions Mean, variance, and covariance
Mean, continuous random variable, Definition 2.34
The mean/expected value of a continuous random variable:
µ =∫
∞
−∞
x f (x)dx
Compare with the mean of a discrete random variable:
µ = ∑all x
x f (x)
Andreas Baum (DTU Compute) Introduction to Statistics Spring 2022 9 / 49
![Page 17: Course 02402 Introduction to Statistics Lecture 3: Random](https://reader030.vdocuments.us/reader030/viewer/2022021408/6209b0641ea8160b220fa197/html5/thumbnails/17.jpg)
Continuous random variables and distributions Mean, variance, and covariance
Variance, continuous random variable, Definition 2.34
The variance of a continuous random variable:
σ2 =
∫∞
−∞
(x−µ)2 f (x)dx
Compare with the variance of a discrete random variable:
σ2 = ∑
all x(x−µ)2 f (x)
Andreas Baum (DTU Compute) Introduction to Statistics Spring 2022 10 / 49
![Page 18: Course 02402 Introduction to Statistics Lecture 3: Random](https://reader030.vdocuments.us/reader030/viewer/2022021408/6209b0641ea8160b220fa197/html5/thumbnails/18.jpg)
Continuous random variables and distributions Mean, variance, and covariance
Variance, continuous random variable, Definition 2.34
The variance of a continuous random variable:
σ2 =
∫∞
−∞
(x−µ)2 f (x)dx
Compare with the variance of a discrete random variable:
σ2 = ∑
all x(x−µ)2 f (x)
Andreas Baum (DTU Compute) Introduction to Statistics Spring 2022 10 / 49
![Page 19: Course 02402 Introduction to Statistics Lecture 3: Random](https://reader030.vdocuments.us/reader030/viewer/2022021408/6209b0641ea8160b220fa197/html5/thumbnails/19.jpg)
Continuous random variables and distributions Mean, variance, and covariance
Covariance, Definition 2.58
The covariance between two random variables:
Let X and Y be two random variables. Then, the covariance between X and Y is
Cov(X,Y) = E[(X−E[X])(Y−E[Y])]
Relationship between covariance and independence:
If two random variables are independent their covariance is 0. The reverse is not
necessarily true!
Andreas Baum (DTU Compute) Introduction to Statistics Spring 2022 11 / 49
![Page 20: Course 02402 Introduction to Statistics Lecture 3: Random](https://reader030.vdocuments.us/reader030/viewer/2022021408/6209b0641ea8160b220fa197/html5/thumbnails/20.jpg)
Specific continuous distributions
Overview
1 Continuous random variables and distributionsDensity and distribution functionsMean, variance, and covariance
2 Specific continuous distributionsThe uniform distributionThe normal distributionThe log-normal distributionThe exponential distribution
3 Calculation rules for random variables
Andreas Baum (DTU Compute) Introduction to Statistics Spring 2022 12 / 49
![Page 21: Course 02402 Introduction to Statistics Lecture 3: Random](https://reader030.vdocuments.us/reader030/viewer/2022021408/6209b0641ea8160b220fa197/html5/thumbnails/21.jpg)
Specific continuous distributions
Specific continuous distributions
A number of statistical distributions exist (both continuous and discrete) that can be
used to describe and analyze different types of problems.
Today, we’ll take a closer look at the following continuous distributions:
The uniform distribution
The normal distribution
The log-normal distribution
The exponential distribution
Andreas Baum (DTU Compute) Introduction to Statistics Spring 2022 13 / 49
![Page 22: Course 02402 Introduction to Statistics Lecture 3: Random](https://reader030.vdocuments.us/reader030/viewer/2022021408/6209b0641ea8160b220fa197/html5/thumbnails/22.jpg)
Specific continuous distributions
Continuous distributions in R
R Distribution
norm The normal distribution
unif The uniform distribution
lnorm The log-normal distribution
exp The exponential distribution
d Probability density function, f (x).
p Cumulative distribution function, F(x).
q Quantile function.
r Random numbers from the distribution.
Andreas Baum (DTU Compute) Introduction to Statistics Spring 2022 14 / 49
![Page 23: Course 02402 Introduction to Statistics Lecture 3: Random](https://reader030.vdocuments.us/reader030/viewer/2022021408/6209b0641ea8160b220fa197/html5/thumbnails/23.jpg)
Specific continuous distributions The uniform distribution
Density of a uniform distribution (example)
3.5 4 4.5 5 5.50
0.2
0.4
0.6
0.8
1
x
Taet
hed,
f(x)
Uniform fordeling U(4,5)Uniform distribution U(4,5)
Den
sity
, f(x
)
U(4,5) distribution
Den
sity
, f(x
)
Andreas Baum (DTU Compute) Introduction to Statistics Spring 2022 15 / 49
![Page 24: Course 02402 Introduction to Statistics Lecture 3: Random](https://reader030.vdocuments.us/reader030/viewer/2022021408/6209b0641ea8160b220fa197/html5/thumbnails/24.jpg)
Specific continuous distributions The uniform distribution
The uniform distribution, Def. 2.35 & Theo. 2.36
Syntax:
X ∼ U(α,β )
Density function:
f (x) = 1β−α
for α ≤ x≤ β
Mean:
µ = α+β
2
Variance:
σ2 = 112 (β −α)2
Andreas Baum (DTU Compute) Introduction to Statistics Spring 2022 16 / 49
![Page 25: Course 02402 Introduction to Statistics Lecture 3: Random](https://reader030.vdocuments.us/reader030/viewer/2022021408/6209b0641ea8160b220fa197/html5/thumbnails/25.jpg)
Specific continuous distributions The uniform distribution
The uniform distribution, Def. 2.35 & Theo. 2.36
Syntax:
X ∼ U(α,β )
Density function:
f (x) = 1β−α
for α ≤ x≤ β
Mean:
µ = α+β
2
Variance:
σ2 = 112 (β −α)2
Andreas Baum (DTU Compute) Introduction to Statistics Spring 2022 16 / 49
![Page 26: Course 02402 Introduction to Statistics Lecture 3: Random](https://reader030.vdocuments.us/reader030/viewer/2022021408/6209b0641ea8160b220fa197/html5/thumbnails/26.jpg)
Specific continuous distributions The uniform distribution
The uniform distribution, Def. 2.35 & Theo. 2.36
Syntax:
X ∼ U(α,β )
Density function:
f (x) = 1β−α
for α ≤ x≤ β
Mean:
µ = α+β
2
Variance:
σ2 = 112 (β −α)2
Andreas Baum (DTU Compute) Introduction to Statistics Spring 2022 16 / 49
![Page 27: Course 02402 Introduction to Statistics Lecture 3: Random](https://reader030.vdocuments.us/reader030/viewer/2022021408/6209b0641ea8160b220fa197/html5/thumbnails/27.jpg)
Specific continuous distributions The uniform distribution
The uniform distribution, Def. 2.35 & Theo. 2.36
Syntax:
X ∼ U(α,β )
Density function:
f (x) = 1β−α
for α ≤ x≤ β
Mean:
µ = α+β
2
Variance:
σ2 = 112 (β −α)2
Andreas Baum (DTU Compute) Introduction to Statistics Spring 2022 16 / 49
![Page 28: Course 02402 Introduction to Statistics Lecture 3: Random](https://reader030.vdocuments.us/reader030/viewer/2022021408/6209b0641ea8160b220fa197/html5/thumbnails/28.jpg)
Specific continuous distributions The uniform distribution
Example 1
Students attending a stats course arrive at a lecture between 8.00 and 8.30. It is assumed
that the arival times can be described by a uniform distribution.
Question:
What is the probability that a randomly selected student arrives between 8.20 and 8.30?
Answer:
10/30 = 1/3
Let X ∼ U(0,30) represent arrival time. Then:
P(20≤ X ≤ 30) = P(X ≤ 30)−P(X ≤ 20) = 1−2/3 = 1/3
punif(30, 0, 30) - punif(20, 0, 30)
[1] 0.33
Andreas Baum (DTU Compute) Introduction to Statistics Spring 2022 17 / 49
![Page 29: Course 02402 Introduction to Statistics Lecture 3: Random](https://reader030.vdocuments.us/reader030/viewer/2022021408/6209b0641ea8160b220fa197/html5/thumbnails/29.jpg)
Specific continuous distributions The uniform distribution
Example 1
Students attending a stats course arrive at a lecture between 8.00 and 8.30. It is assumed
that the arival times can be described by a uniform distribution.
Question:
What is the probability that a randomly selected student arrives between 8.20 and 8.30?
Answer:
10/30 = 1/3
Let X ∼ U(0,30) represent arrival time. Then:
P(20≤ X ≤ 30) = P(X ≤ 30)−P(X ≤ 20) = 1−2/3 = 1/3
punif(30, 0, 30) - punif(20, 0, 30)
[1] 0.33
Andreas Baum (DTU Compute) Introduction to Statistics Spring 2022 17 / 49
![Page 30: Course 02402 Introduction to Statistics Lecture 3: Random](https://reader030.vdocuments.us/reader030/viewer/2022021408/6209b0641ea8160b220fa197/html5/thumbnails/30.jpg)
Specific continuous distributions The uniform distribution
Example 1 (continued)
Question:
What is the probability that a randomly selected student arrives after 8.30?
Answer:
0
Let X ∼ U(0,30) represent arrival time. Then:
P(X > 30) = 1−P(X ≤ 30) = 1−1 = 0
1 - punif(30, 0, 30)
[1] 0
Andreas Baum (DTU Compute) Introduction to Statistics Spring 2022 18 / 49
![Page 31: Course 02402 Introduction to Statistics Lecture 3: Random](https://reader030.vdocuments.us/reader030/viewer/2022021408/6209b0641ea8160b220fa197/html5/thumbnails/31.jpg)
Specific continuous distributions The uniform distribution
Example 1 (continued)
Question:
What is the probability that a randomly selected student arrives after 8.30?
Answer:
0
Let X ∼ U(0,30) represent arrival time. Then:
P(X > 30) = 1−P(X ≤ 30) = 1−1 = 0
1 - punif(30, 0, 30)
[1] 0
Andreas Baum (DTU Compute) Introduction to Statistics Spring 2022 18 / 49
![Page 32: Course 02402 Introduction to Statistics Lecture 3: Random](https://reader030.vdocuments.us/reader030/viewer/2022021408/6209b0641ea8160b220fa197/html5/thumbnails/32.jpg)
Specific continuous distributions The normal distribution
Density of a normal distribution (example)
−5 −4 −3 −2 −1 0 1 2 3 4 50
0.05
0.1
0.15
0.2
0.25
0.3
0.35
0.4
0.45
0.5Normalfordeling
x
Taet
hed,
f(x)
Den
sity
, f(x
)
Normal distribution
Andreas Baum (DTU Compute) Introduction to Statistics Spring 2022 19 / 49
![Page 33: Course 02402 Introduction to Statistics Lecture 3: Random](https://reader030.vdocuments.us/reader030/viewer/2022021408/6209b0641ea8160b220fa197/html5/thumbnails/33.jpg)
Specific continuous distributions The normal distribution
The normal distribution, Def. 2.37 & Theo. 2.38
Syntax:
X ∼ N(µ,σ2)
Density function:
f (x) = 1σ√
2πe−
(x−µ)2
2σ2 for −∞ < x < ∞
Mean:
µ = µ
Variance:
σ2 = σ2
Andreas Baum (DTU Compute) Introduction to Statistics Spring 2022 20 / 49
![Page 34: Course 02402 Introduction to Statistics Lecture 3: Random](https://reader030.vdocuments.us/reader030/viewer/2022021408/6209b0641ea8160b220fa197/html5/thumbnails/34.jpg)
Specific continuous distributions The normal distribution
The normal distribution, Def. 2.37 & Theo. 2.38
Syntax:
X ∼ N(µ,σ2)
Density function:
f (x) = 1σ√
2πe−
(x−µ)2
2σ2 for −∞ < x < ∞
Mean:
µ = µ
Variance:
σ2 = σ2
Andreas Baum (DTU Compute) Introduction to Statistics Spring 2022 20 / 49
![Page 35: Course 02402 Introduction to Statistics Lecture 3: Random](https://reader030.vdocuments.us/reader030/viewer/2022021408/6209b0641ea8160b220fa197/html5/thumbnails/35.jpg)
Specific continuous distributions The normal distribution
The normal distribution, Def. 2.37 & Theo. 2.38
Syntax:
X ∼ N(µ,σ2)
Density function:
f (x) = 1σ√
2πe−
(x−µ)2
2σ2 for −∞ < x < ∞
Mean:
µ = µ
Variance:
σ2 = σ2
Andreas Baum (DTU Compute) Introduction to Statistics Spring 2022 20 / 49
![Page 36: Course 02402 Introduction to Statistics Lecture 3: Random](https://reader030.vdocuments.us/reader030/viewer/2022021408/6209b0641ea8160b220fa197/html5/thumbnails/36.jpg)
Specific continuous distributions The normal distribution
The normal distribution, Def. 2.37 & Theo. 2.38
Syntax:
X ∼ N(µ,σ2)
Density function:
f (x) = 1σ√
2πe−
(x−µ)2
2σ2 for −∞ < x < ∞
Mean:
µ = µ
Variance:
σ2 = σ2
Andreas Baum (DTU Compute) Introduction to Statistics Spring 2022 20 / 49
![Page 37: Course 02402 Introduction to Statistics Lecture 3: Random](https://reader030.vdocuments.us/reader030/viewer/2022021408/6209b0641ea8160b220fa197/html5/thumbnails/37.jpg)
Specific continuous distributions The normal distribution
Density of a standard normal distribution
−5 −4 −3 −2 −1 0 1 2 3 4 5−0.05
0
0.05
0.1
0.15
0.2
0.25
0.3
0.35
0.4
0.45
−2σ −σ µ−3σ 3σ2σσ
x
Taet
hed,
f(x)
Normalfordeling N(0,12)D
ensi
ty, f
(x)(Standard) normal distribution N(0,1)
Andreas Baum (DTU Compute) Introduction to Statistics Spring 2022 21 / 49
![Page 38: Course 02402 Introduction to Statistics Lecture 3: Random](https://reader030.vdocuments.us/reader030/viewer/2022021408/6209b0641ea8160b220fa197/html5/thumbnails/38.jpg)
Specific continuous distributions The normal distribution
Density of two normal distributions (example)
−5 0 5 10−0.05
0
0.05
0.1
0.15
0.2
0.25
0.3
0.35
0.4
0.45 N(0,12) N(5,12)
Sammenligning af to normalfordelinger med forskellig middelvardi og ens variansTwo different normal distributions: Different means, same variance
Andreas Baum (DTU Compute) Introduction to Statistics Spring 2022 22 / 49
![Page 39: Course 02402 Introduction to Statistics Lecture 3: Random](https://reader030.vdocuments.us/reader030/viewer/2022021408/6209b0641ea8160b220fa197/html5/thumbnails/39.jpg)
Specific continuous distributions The normal distribution
Density of three normal distributions (example)
−10 −8 −6 −4 −2 0 2 4 6 8 10
0
0.1
0.2
0.3
0.4
0.5
Sammenligning af tre normalfordelinger med ens middelvardi og forskellig varians
x
Taet
hed,
f(x)
Den
sity
, f(x
)
Three different normal distributions: Same mean, difference variances
Andreas Baum (DTU Compute) Introduction to Statistics Spring 2022 23 / 49
![Page 40: Course 02402 Introduction to Statistics Lecture 3: Random](https://reader030.vdocuments.us/reader030/viewer/2022021408/6209b0641ea8160b220fa197/html5/thumbnails/40.jpg)
Specific continuous distributions The normal distribution
The standard normal distribution
The standard normal distribution:
Z ∼ N(0,12)
The normal distribution with mean 0 and variance 1.
Standardization:
An arbitrary normal distributed variable X ∼ N(µ,σ2) can be standardized by
Z =X−µ
σ
Andreas Baum (DTU Compute) Introduction to Statistics Spring 2022 24 / 49
![Page 41: Course 02402 Introduction to Statistics Lecture 3: Random](https://reader030.vdocuments.us/reader030/viewer/2022021408/6209b0641ea8160b220fa197/html5/thumbnails/41.jpg)
Specific continuous distributions The normal distribution
The standard normal distribution
The standard normal distribution:
Z ∼ N(0,12)
The normal distribution with mean 0 and variance 1.
Standardization:
An arbitrary normal distributed variable X ∼ N(µ,σ2) can be standardized by
Z =X−µ
σ
Andreas Baum (DTU Compute) Introduction to Statistics Spring 2022 24 / 49
![Page 42: Course 02402 Introduction to Statistics Lecture 3: Random](https://reader030.vdocuments.us/reader030/viewer/2022021408/6209b0641ea8160b220fa197/html5/thumbnails/42.jpg)
Specific continuous distributions The normal distribution
Example 2
Measurement error:
A scale has a measurement error, Z, that can be described by the standard normal
distribution, i.e.
Z ∼ N(0,12) .
That is, the mean measurement error is µ = 0 with standard deviation σ = 1 gram. The
scale is used to measure the weight of a product.
Question a):
What is the probability that the scale yields a measurement which is at least 2 grams
smaller than the true weight of the product?
Answer:
P(Z ≤−2) = 0.02275
pnorm(-2)
Andreas Baum (DTU Compute) Introduction to Statistics Spring 2022 25 / 49
![Page 43: Course 02402 Introduction to Statistics Lecture 3: Random](https://reader030.vdocuments.us/reader030/viewer/2022021408/6209b0641ea8160b220fa197/html5/thumbnails/43.jpg)
Specific continuous distributions The normal distribution
Example 2
Measurement error:
A scale has a measurement error, Z, that can be described by the standard normal
distribution, i.e.
Z ∼ N(0,12) .
That is, the mean measurement error is µ = 0 with standard deviation σ = 1 gram. The
scale is used to measure the weight of a product.
Question a):
What is the probability that the scale yields a measurement which is at least 2 grams
smaller than the true weight of the product?
Answer:
P(Z ≤−2) = 0.02275
pnorm(-2)
Andreas Baum (DTU Compute) Introduction to Statistics Spring 2022 25 / 49
![Page 44: Course 02402 Introduction to Statistics Lecture 3: Random](https://reader030.vdocuments.us/reader030/viewer/2022021408/6209b0641ea8160b220fa197/html5/thumbnails/44.jpg)
Specific continuous distributions The normal distribution
Example 2
Measurement error:
A scale has a measurement error, Z, that can be described by the standard normal
distribution, i.e.
Z ∼ N(0,12) .
That is, the mean measurement error is µ = 0 with standard deviation σ = 1 gram. The
scale is used to measure the weight of a product.
Question a):
What is the probability that the scale yields a measurement which is at least 2 grams
smaller than the true weight of the product?
Answer:
P(Z ≤−2) = 0.02275
pnorm(-2)
Andreas Baum (DTU Compute) Introduction to Statistics Spring 2022 25 / 49
![Page 45: Course 02402 Introduction to Statistics Lecture 3: Random](https://reader030.vdocuments.us/reader030/viewer/2022021408/6209b0641ea8160b220fa197/html5/thumbnails/45.jpg)
Specific continuous distributions The normal distribution
Example 2
Answer:
pnorm(-2)
[1] 0.023
z
dnor
m(z
)
−3 −2 −1 0 1 2 3
Andreas Baum (DTU Compute) Introduction to Statistics Spring 2022 26 / 49
![Page 46: Course 02402 Introduction to Statistics Lecture 3: Random](https://reader030.vdocuments.us/reader030/viewer/2022021408/6209b0641ea8160b220fa197/html5/thumbnails/46.jpg)
Specific continuous distributions The normal distribution
Example 2
Question b):
What is the probability that the scale yields a measurement which is at least 2 grams
larger than the true weight of the product?
Answer:
P(Z ≥ 2) = 0.02275
1 - pnorm(2)
z
dnor
m(z
)
−3 −2 −1 0 1 2 3
Andreas Baum (DTU Compute) Introduction to Statistics Spring 2022 27 / 49
![Page 47: Course 02402 Introduction to Statistics Lecture 3: Random](https://reader030.vdocuments.us/reader030/viewer/2022021408/6209b0641ea8160b220fa197/html5/thumbnails/47.jpg)
Specific continuous distributions The normal distribution
Example 2
Question b):
What is the probability that the scale yields a measurement which is at least 2 grams
larger than the true weight of the product?
Answer:
P(Z ≥ 2) = 0.02275
1 - pnorm(2)
z
dnor
m(z
)
−3 −2 −1 0 1 2 3
Andreas Baum (DTU Compute) Introduction to Statistics Spring 2022 27 / 49
![Page 48: Course 02402 Introduction to Statistics Lecture 3: Random](https://reader030.vdocuments.us/reader030/viewer/2022021408/6209b0641ea8160b220fa197/html5/thumbnails/48.jpg)
Specific continuous distributions The normal distribution
Example 2
Question c):
What is the probability that the scale is off by at most ±1 gram?
Answer:
P(|Z| ≤ 1) = P(−1≤ Z ≤ 1) = P(Z ≤ 1)−P(Z ≤−1) = 0.683
pnorm(1) - pnorm(-1)
z
dnor
m(z
)
−3 −2 −1 0 1 2 3
Andreas Baum (DTU Compute) Introduction to Statistics Spring 2022 28 / 49
![Page 49: Course 02402 Introduction to Statistics Lecture 3: Random](https://reader030.vdocuments.us/reader030/viewer/2022021408/6209b0641ea8160b220fa197/html5/thumbnails/49.jpg)
Specific continuous distributions The normal distribution
Example 2
Question c):
What is the probability that the scale is off by at most ±1 gram?
Answer:
P(|Z| ≤ 1) = P(−1≤ Z ≤ 1) = P(Z ≤ 1)−P(Z ≤−1) = 0.683
pnorm(1) - pnorm(-1)
z
dnor
m(z
)
−3 −2 −1 0 1 2 3
Andreas Baum (DTU Compute) Introduction to Statistics Spring 2022 28 / 49
![Page 50: Course 02402 Introduction to Statistics Lecture 3: Random](https://reader030.vdocuments.us/reader030/viewer/2022021408/6209b0641ea8160b220fa197/html5/thumbnails/50.jpg)
Specific continuous distributions The normal distribution
Example 3
Income distribution:
It is assumed that the annual salary distribution of elementary school teachers can be
described using a normal distribution with mean µ = 290 (in DKK thousand) and
standard deviation σ = 4 (DKK thousand).
Question a):
What is the probability that a randomly selected teacher earns more than DKK 300.000?
Andreas Baum (DTU Compute) Introduction to Statistics Spring 2022 29 / 49
![Page 51: Course 02402 Introduction to Statistics Lecture 3: Random](https://reader030.vdocuments.us/reader030/viewer/2022021408/6209b0641ea8160b220fa197/html5/thumbnails/51.jpg)
Specific continuous distributions The normal distribution
Example 3
Income distribution:
It is assumed that the annual salary distribution of elementary school teachers can be
described using a normal distribution with mean µ = 290 (in DKK thousand) and
standard deviation σ = 4 (DKK thousand).
Question a):
What is the probability that a randomly selected teacher earns more than DKK 300.000?
Andreas Baum (DTU Compute) Introduction to Statistics Spring 2022 29 / 49
![Page 52: Course 02402 Introduction to Statistics Lecture 3: Random](https://reader030.vdocuments.us/reader030/viewer/2022021408/6209b0641ea8160b220fa197/html5/thumbnails/52.jpg)
Specific continuous distributions The normal distribution
Example 3
Question a):
What is the probability that a randomly selected teacher earns more than DKK 300.000?
Answer:
1 - pnorm(300, m = 290, s = 4)
[1] 0.0062
z
dnor
m(z
)
278 282 286 290 294 298 302
Andreas Baum (DTU Compute) Introduction to Statistics Spring 2022 30 / 49
![Page 53: Course 02402 Introduction to Statistics Lecture 3: Random](https://reader030.vdocuments.us/reader030/viewer/2022021408/6209b0641ea8160b220fa197/html5/thumbnails/53.jpg)
Specific continuous distributions The normal distribution
Example 3
Question a):
What is the probability that a randomly selected teacher earns more than DKK 300.000?
Answer:
1 - pnorm(300, m = 290, s = 4)
[1] 0.0062
z
dnor
m(z
)
278 282 286 290 294 298 302
Andreas Baum (DTU Compute) Introduction to Statistics Spring 2022 30 / 49
![Page 54: Course 02402 Introduction to Statistics Lecture 3: Random](https://reader030.vdocuments.us/reader030/viewer/2022021408/6209b0641ea8160b220fa197/html5/thumbnails/54.jpg)
Specific continuous distributions The normal distribution
Example 4
(Same income distribution):
It is assumed that the annual salary distribution of elementary school teachers can be
described using a normal distribution with mean µ = 290 (DKK thousand) and standard
deviation σ = 4 (DKK thousand).
”Opposite question”
Give a salary interval (symmetric around the mean) which covers 95% of all teachers’
salary.
Answer:
qnorm(c(0.025, 0.975), m = 290, s = 4)
[1] 282 298
Andreas Baum (DTU Compute) Introduction to Statistics Spring 2022 31 / 49
![Page 55: Course 02402 Introduction to Statistics Lecture 3: Random](https://reader030.vdocuments.us/reader030/viewer/2022021408/6209b0641ea8160b220fa197/html5/thumbnails/55.jpg)
Specific continuous distributions The normal distribution
Example 4
(Same income distribution):
It is assumed that the annual salary distribution of elementary school teachers can be
described using a normal distribution with mean µ = 290 (DKK thousand) and standard
deviation σ = 4 (DKK thousand).
”Opposite question”
Give a salary interval (symmetric around the mean) which covers 95% of all teachers’
salary.
Answer:
qnorm(c(0.025, 0.975), m = 290, s = 4)
[1] 282 298
Andreas Baum (DTU Compute) Introduction to Statistics Spring 2022 31 / 49
![Page 56: Course 02402 Introduction to Statistics Lecture 3: Random](https://reader030.vdocuments.us/reader030/viewer/2022021408/6209b0641ea8160b220fa197/html5/thumbnails/56.jpg)
Specific continuous distributions The normal distribution
Example 4
(Same income distribution):
It is assumed that the annual salary distribution of elementary school teachers can be
described using a normal distribution with mean µ = 290 (DKK thousand) and standard
deviation σ = 4 (DKK thousand).
”Opposite question”
Give a salary interval (symmetric around the mean) which covers 95% of all teachers’
salary.
Answer:
qnorm(c(0.025, 0.975), m = 290, s = 4)
[1] 282 298
Andreas Baum (DTU Compute) Introduction to Statistics Spring 2022 31 / 49
![Page 57: Course 02402 Introduction to Statistics Lecture 3: Random](https://reader030.vdocuments.us/reader030/viewer/2022021408/6209b0641ea8160b220fa197/html5/thumbnails/57.jpg)
Specific continuous distributions The log-normal distribution
The log-normal distribution
0 5 10 15 20 25 300
0.05
0.1
0.15
0.2
0.25
LN(1,1)
x
Taet
hed,
f(x)
Log−Normalfordeling LN(1,1)Log-normal distribution LN(1,1)
Den
sity
, f(x
)
Andreas Baum (DTU Compute) Introduction to Statistics Spring 2022 32 / 49
![Page 58: Course 02402 Introduction to Statistics Lecture 3: Random](https://reader030.vdocuments.us/reader030/viewer/2022021408/6209b0641ea8160b220fa197/html5/thumbnails/58.jpg)
Specific continuous distributions The log-normal distribution
The log-normal distribution, Def. 2.46 & Theo. 2.47
Syntax:
X ∼ LN(α,β 2) (with β > 0)
Density function:
f (x) =
{1
β√
2πx−1e−(ln(x)−α)2/2β 2
x > 00 otherwise
Mean:
µ = eα+β 2/2
Variance:
σ2 = e2α+β 2(eβ 2 −1)
Andreas Baum (DTU Compute) Introduction to Statistics Spring 2022 33 / 49
![Page 59: Course 02402 Introduction to Statistics Lecture 3: Random](https://reader030.vdocuments.us/reader030/viewer/2022021408/6209b0641ea8160b220fa197/html5/thumbnails/59.jpg)
Specific continuous distributions The log-normal distribution
The log-normal distribution, Def. 2.46 & Theo. 2.47
Syntax:
X ∼ LN(α,β 2) (with β > 0)
Density function:
f (x) =
{1
β√
2πx−1e−(ln(x)−α)2/2β 2
x > 00 otherwise
Mean:
µ = eα+β 2/2
Variance:
σ2 = e2α+β 2(eβ 2 −1)
Andreas Baum (DTU Compute) Introduction to Statistics Spring 2022 33 / 49
![Page 60: Course 02402 Introduction to Statistics Lecture 3: Random](https://reader030.vdocuments.us/reader030/viewer/2022021408/6209b0641ea8160b220fa197/html5/thumbnails/60.jpg)
Specific continuous distributions The log-normal distribution
The log-normal distribution, Def. 2.46 & Theo. 2.47
Syntax:
X ∼ LN(α,β 2) (with β > 0)
Density function:
f (x) =
{1
β√
2πx−1e−(ln(x)−α)2/2β 2
x > 00 otherwise
Mean:
µ = eα+β 2/2
Variance:
σ2 = e2α+β 2(eβ 2 −1)
Andreas Baum (DTU Compute) Introduction to Statistics Spring 2022 33 / 49
![Page 61: Course 02402 Introduction to Statistics Lecture 3: Random](https://reader030.vdocuments.us/reader030/viewer/2022021408/6209b0641ea8160b220fa197/html5/thumbnails/61.jpg)
Specific continuous distributions The log-normal distribution
The log-normal distribution, Def. 2.46 & Theo. 2.47
Syntax:
X ∼ LN(α,β 2) (with β > 0)
Density function:
f (x) =
{1
β√
2πx−1e−(ln(x)−α)2/2β 2
x > 00 otherwise
Mean:
µ = eα+β 2/2
Variance:
σ2 = e2α+β 2(eβ 2 −1)
Andreas Baum (DTU Compute) Introduction to Statistics Spring 2022 33 / 49
![Page 62: Course 02402 Introduction to Statistics Lecture 3: Random](https://reader030.vdocuments.us/reader030/viewer/2022021408/6209b0641ea8160b220fa197/html5/thumbnails/62.jpg)
Specific continuous distributions The log-normal distribution
The log-normal distribution
Log-normal and normal distributions:
A log-normal distributed variable Y ∼ LN(α,β 2) can be transformed into a normal
distributed variable:
X = ln(Y)
is normal distributed with mean α and variance β 2, i.e. X ∼ N(α,β 2).
Z =ln(Y)−α
β
is standard normal distributed, i.e. Z ∼ N(0,1).
Andreas Baum (DTU Compute) Introduction to Statistics Spring 2022 34 / 49
![Page 63: Course 02402 Introduction to Statistics Lecture 3: Random](https://reader030.vdocuments.us/reader030/viewer/2022021408/6209b0641ea8160b220fa197/html5/thumbnails/63.jpg)
Specific continuous distributions The exponential distribution
The exponential distribution
−1 0 1 2 3 4 5 6 7 8 9 100
0.2
0.4
0.6
0.8
1
EXP(1)
x
Taet
hed,
f(x)
Eksponential fordeling med β=1
Den
sity
, f(x
)
Exponential distribution Exp(1)
Andreas Baum (DTU Compute) Introduction to Statistics Spring 2022 35 / 49
![Page 64: Course 02402 Introduction to Statistics Lecture 3: Random](https://reader030.vdocuments.us/reader030/viewer/2022021408/6209b0641ea8160b220fa197/html5/thumbnails/64.jpg)
Specific continuous distributions The exponential distribution
The exponential distribution, Def. 2.48 & Theo. 2.49
Syntax:
X ∼ Exp(λ )
with λ > 0.
Density function:
f (x) ={
λe−λx x≥ 00 otherwise
Mean:
µ =1λ
Variance:
σ2 =
1λ 2
Andreas Baum (DTU Compute) Introduction to Statistics Spring 2022 36 / 49
![Page 65: Course 02402 Introduction to Statistics Lecture 3: Random](https://reader030.vdocuments.us/reader030/viewer/2022021408/6209b0641ea8160b220fa197/html5/thumbnails/65.jpg)
Specific continuous distributions The exponential distribution
The exponential distribution
The exponential distribution is a special case of the gamma distribution.
The exponential distribution is used to describe lifespan and waiting times.
The exponential distribution can be used to describe (waiting) time between
Poisson events.
Andreas Baum (DTU Compute) Introduction to Statistics Spring 2022 37 / 49
![Page 66: Course 02402 Introduction to Statistics Lecture 3: Random](https://reader030.vdocuments.us/reader030/viewer/2022021408/6209b0641ea8160b220fa197/html5/thumbnails/66.jpg)
Specific continuous distributions The exponential distribution
Connection between the exponential and Poissondistributions
time t
∗ ∗ ∗ ∗ ∗ ∗ ∗
t1 t2
Poisson: Discrete events per unit
Exponential: Continuous distance between events
Andreas Baum (DTU Compute) Introduction to Statistics Spring 2022 38 / 49
![Page 67: Course 02402 Introduction to Statistics Lecture 3: Random](https://reader030.vdocuments.us/reader030/viewer/2022021408/6209b0641ea8160b220fa197/html5/thumbnails/67.jpg)
Specific continuous distributions The exponential distribution
Example 5
Queuing model – Poisson process
The time between customer arrivals at a post office is exponentially distributed with
mean µ = 2 minutes.
Question:
One customer has just arrived. What is the probability that no other customers will arrive
during the next 2 minutes?
Answer:
X ∼ Exp(1/2) represents waiting time until next customer.
P(X > 2) = 1−P(X ≤ 2)
1 - pexp(2, rate = 1/2)
[1] 0.37
Andreas Baum (DTU Compute) Introduction to Statistics Spring 2022 39 / 49
![Page 68: Course 02402 Introduction to Statistics Lecture 3: Random](https://reader030.vdocuments.us/reader030/viewer/2022021408/6209b0641ea8160b220fa197/html5/thumbnails/68.jpg)
Specific continuous distributions The exponential distribution
Example 5
Queuing model – Poisson process
The time between customer arrivals at a post office is exponentially distributed with
mean µ = 2 minutes.
Question:
One customer has just arrived. What is the probability that no other customers will arrive
during the next 2 minutes?
Answer:
X ∼ Exp(1/2) represents waiting time until next customer.
P(X > 2) = 1−P(X ≤ 2)
1 - pexp(2, rate = 1/2)
[1] 0.37
Andreas Baum (DTU Compute) Introduction to Statistics Spring 2022 39 / 49
![Page 69: Course 02402 Introduction to Statistics Lecture 3: Random](https://reader030.vdocuments.us/reader030/viewer/2022021408/6209b0641ea8160b220fa197/html5/thumbnails/69.jpg)
Specific continuous distributions The exponential distribution
Example 5
Queuing model – Poisson process
The time between customer arrivals at a post office is exponentially distributed with
mean µ = 2 minutes.
Question:
One customer has just arrived. What is the probability that no other customers will arrive
during the next 2 minutes?
Answer:
X ∼ Exp(1/2) represents waiting time until next customer.
P(X > 2) = 1−P(X ≤ 2)
1 - pexp(2, rate = 1/2)
[1] 0.37
Andreas Baum (DTU Compute) Introduction to Statistics Spring 2022 39 / 49
![Page 70: Course 02402 Introduction to Statistics Lecture 3: Random](https://reader030.vdocuments.us/reader030/viewer/2022021408/6209b0641ea8160b220fa197/html5/thumbnails/70.jpg)
Specific continuous distributions The exponential distribution
Example 5
0 2 4 6 8
0.0
0.1
0.2
0.3
0.4
0.5
Exp(1/2) − distribution
z
dexp
(z, 1
/2)
P(X > 2) = 0.37
P(X < 2) = 0.63
Andreas Baum (DTU Compute) Introduction to Statistics Spring 2022 40 / 49
![Page 71: Course 02402 Introduction to Statistics Lecture 3: Random](https://reader030.vdocuments.us/reader030/viewer/2022021408/6209b0641ea8160b220fa197/html5/thumbnails/71.jpg)
Specific continuous distributions The exponential distribution
Example 6
Question:
One customer has just arrived. Use the Poisson distribution to calculate the probability
that no other costumers will arrive during the next two minutes.
Answer:
λ2min = 1, P(X = 0) = e−1
1! 10 = e−1
dpois(0,1)
[1] 0.37
exp(-1)
[1] 0.37
Andreas Baum (DTU Compute) Introduction to Statistics Spring 2022 41 / 49
![Page 72: Course 02402 Introduction to Statistics Lecture 3: Random](https://reader030.vdocuments.us/reader030/viewer/2022021408/6209b0641ea8160b220fa197/html5/thumbnails/72.jpg)
Specific continuous distributions The exponential distribution
Example 6
Question:
One customer has just arrived. Use the Poisson distribution to calculate the probability
that no other costumers will arrive during the next two minutes.
Answer:
λ2min = 1, P(X = 0) = e−1
1! 10 = e−1
dpois(0,1)
[1] 0.37
exp(-1)
[1] 0.37
Andreas Baum (DTU Compute) Introduction to Statistics Spring 2022 41 / 49
![Page 73: Course 02402 Introduction to Statistics Lecture 3: Random](https://reader030.vdocuments.us/reader030/viewer/2022021408/6209b0641ea8160b220fa197/html5/thumbnails/73.jpg)
Calculation rules for random variables
Overview
1 Continuous random variables and distributionsDensity and distribution functionsMean, variance, and covariance
2 Specific continuous distributionsThe uniform distributionThe normal distributionThe log-normal distributionThe exponential distribution
3 Calculation rules for random variables
Andreas Baum (DTU Compute) Introduction to Statistics Spring 2022 42 / 49
![Page 74: Course 02402 Introduction to Statistics Lecture 3: Random](https://reader030.vdocuments.us/reader030/viewer/2022021408/6209b0641ea8160b220fa197/html5/thumbnails/74.jpg)
Calculation rules for random variables
Calculation rules for random variables
These rules work for both continuous and discrete random variables!
X is a random variable, a and b are constants.
Mean rule:
E(aX+b) = aE(X)+b
Variance rule:
Var(aX+b) = a2Var(X)
Andreas Baum (DTU Compute) Introduction to Statistics Spring 2022 43 / 49
![Page 75: Course 02402 Introduction to Statistics Lecture 3: Random](https://reader030.vdocuments.us/reader030/viewer/2022021408/6209b0641ea8160b220fa197/html5/thumbnails/75.jpg)
Calculation rules for random variables
Calculation rules for random variables
These rules work for both continuous and discrete random variables!
X is a random variable, a and b are constants.
Mean rule:
E(aX+b) = aE(X)+b
Variance rule:
Var(aX+b) = a2Var(X)
Andreas Baum (DTU Compute) Introduction to Statistics Spring 2022 43 / 49
![Page 76: Course 02402 Introduction to Statistics Lecture 3: Random](https://reader030.vdocuments.us/reader030/viewer/2022021408/6209b0641ea8160b220fa197/html5/thumbnails/76.jpg)
Calculation rules for random variables
Calculation rules for random variables
These rules work for both continuous and discrete random variables!
X is a random variable, a and b are constants.
Mean rule:
E(aX+b) = aE(X)+b
Variance rule:
Var(aX+b) = a2Var(X)
Andreas Baum (DTU Compute) Introduction to Statistics Spring 2022 43 / 49
![Page 77: Course 02402 Introduction to Statistics Lecture 3: Random](https://reader030.vdocuments.us/reader030/viewer/2022021408/6209b0641ea8160b220fa197/html5/thumbnails/77.jpg)
Calculation rules for random variables
Example 7
X is a random variable with mean 4 and variance 6.
Question:
Calculate the mean and variance of Y =−3X+2
Answer:
E(Y) =−3E(X)+2 =−3 ·4+2 =−10
Var(Y) = (−3)2Var(X) = 9 ·6 = 54
Andreas Baum (DTU Compute) Introduction to Statistics Spring 2022 44 / 49
![Page 78: Course 02402 Introduction to Statistics Lecture 3: Random](https://reader030.vdocuments.us/reader030/viewer/2022021408/6209b0641ea8160b220fa197/html5/thumbnails/78.jpg)
Calculation rules for random variables
Example 7
X is a random variable with mean 4 and variance 6.
Question:
Calculate the mean and variance of Y =−3X+2
Answer:
E(Y) =−3E(X)+2 =−3 ·4+2 =−10
Var(Y) = (−3)2Var(X) = 9 ·6 = 54
Andreas Baum (DTU Compute) Introduction to Statistics Spring 2022 44 / 49
![Page 79: Course 02402 Introduction to Statistics Lecture 3: Random](https://reader030.vdocuments.us/reader030/viewer/2022021408/6209b0641ea8160b220fa197/html5/thumbnails/79.jpg)
Calculation rules for random variables
Calculation rules for random variables
X1, . . . ,Xn are independent random variables.
Mean rule:
E(a1X1 +a2X2 + · · ·+anXn)
= a1E(X1)+a2E(X2)+ · · ·+anE(Xn)
Variance rule:
Var(a1X1 +a2X2 + · · ·+anXn)
= a21Var(X1)+ · · ·+a2
nVar(Xn)
Andreas Baum (DTU Compute) Introduction to Statistics Spring 2022 45 / 49
![Page 80: Course 02402 Introduction to Statistics Lecture 3: Random](https://reader030.vdocuments.us/reader030/viewer/2022021408/6209b0641ea8160b220fa197/html5/thumbnails/80.jpg)
Calculation rules for random variables
Calculation rules for random variables
X1, . . . ,Xn are independent random variables.
Mean rule:
E(a1X1 +a2X2 + · · ·+anXn)
= a1E(X1)+a2E(X2)+ · · ·+anE(Xn)
Variance rule:
Var(a1X1 +a2X2 + · · ·+anXn)
= a21Var(X1)+ · · ·+a2
nVar(Xn)
Andreas Baum (DTU Compute) Introduction to Statistics Spring 2022 45 / 49
![Page 81: Course 02402 Introduction to Statistics Lecture 3: Random](https://reader030.vdocuments.us/reader030/viewer/2022021408/6209b0641ea8160b220fa197/html5/thumbnails/81.jpg)
Calculation rules for random variables
Calculation rules for random variables
X1, . . . ,Xn are independent random variables.
Mean rule:
E(a1X1 +a2X2 + · · ·+anXn)
= a1E(X1)+a2E(X2)+ · · ·+anE(Xn)
Variance rule:
Var(a1X1 +a2X2 + · · ·+anXn)
= a21Var(X1)+ · · ·+a2
nVar(Xn)
Andreas Baum (DTU Compute) Introduction to Statistics Spring 2022 45 / 49
![Page 82: Course 02402 Introduction to Statistics Lecture 3: Random](https://reader030.vdocuments.us/reader030/viewer/2022021408/6209b0641ea8160b220fa197/html5/thumbnails/82.jpg)
Calculation rules for random variables
Example 8
Airline Planning
The weight of each passenger on a flight is assumed to be normal distributed
X ∼ N(70,102).
A plane, which can take 55 passengers, may not have a load exceeding 4000 kg (only the
weight of the passengers is considered load).
Question:
Calculate the probability that the plain is overloaded
What is Y = Total passenger weight?
What is Y?
Definitely NOT: Y = 55 ·X
Andreas Baum (DTU Compute) Introduction to Statistics Spring 2022 46 / 49
![Page 83: Course 02402 Introduction to Statistics Lecture 3: Random](https://reader030.vdocuments.us/reader030/viewer/2022021408/6209b0641ea8160b220fa197/html5/thumbnails/83.jpg)
Calculation rules for random variables
Example 8
Airline Planning
The weight of each passenger on a flight is assumed to be normal distributed
X ∼ N(70,102).
A plane, which can take 55 passengers, may not have a load exceeding 4000 kg (only the
weight of the passengers is considered load).
Question:
Calculate the probability that the plain is overloaded
What is Y = Total passenger weight?
What is Y?
Definitely NOT: Y = 55 ·X
Andreas Baum (DTU Compute) Introduction to Statistics Spring 2022 46 / 49
![Page 84: Course 02402 Introduction to Statistics Lecture 3: Random](https://reader030.vdocuments.us/reader030/viewer/2022021408/6209b0641ea8160b220fa197/html5/thumbnails/84.jpg)
Calculation rules for random variables
Example 8
Airline Planning
The weight of each passenger on a flight is assumed to be normal distributed
X ∼ N(70,102).
A plane, which can take 55 passengers, may not have a load exceeding 4000 kg (only the
weight of the passengers is considered load).
Question:
Calculate the probability that the plain is overloaded
What is Y = Total passenger weight?
What is Y?
Definitely NOT: Y = 55 ·X
Andreas Baum (DTU Compute) Introduction to Statistics Spring 2022 46 / 49
![Page 85: Course 02402 Introduction to Statistics Lecture 3: Random](https://reader030.vdocuments.us/reader030/viewer/2022021408/6209b0641ea8160b220fa197/html5/thumbnails/85.jpg)
Calculation rules for random variables
Example 8
Airline Planning
The weight of each passenger on a flight is assumed to be normal distributed
X ∼ N(70,102).
A plane, which can take 55 passengers, may not have a load exceeding 4000 kg (only the
weight of the passengers is considered load).
Question:
Calculate the probability that the plain is overloaded
What is Y = Total passenger weight?
What is Y?
Definitely NOT: Y = 55 ·X
Andreas Baum (DTU Compute) Introduction to Statistics Spring 2022 46 / 49
![Page 86: Course 02402 Introduction to Statistics Lecture 3: Random](https://reader030.vdocuments.us/reader030/viewer/2022021408/6209b0641ea8160b220fa197/html5/thumbnails/86.jpg)
Calculation rules for random variables
Example 8
What is Y = Total passenger weight?
Y = ∑55i=1 Xi, where Xi ∼ N(70,102) (and assumed to be independent)
Mean and variance of Y:
E(Y) =55
∑i=1
E(Xi) =55
∑i=1
70 = 55 ·70 = 3850
Var(Y) =55
∑i=1
Var(Xi) =55
∑i=1
100 = 55 ·100 = 5500
Y is normal distributed, so we may find P(Y > 4000) using:
1-pnorm(4000, mean = 3850, sd = sqrt(5500))
[1] 0.022
Andreas Baum (DTU Compute) Introduction to Statistics Spring 2022 47 / 49
![Page 87: Course 02402 Introduction to Statistics Lecture 3: Random](https://reader030.vdocuments.us/reader030/viewer/2022021408/6209b0641ea8160b220fa197/html5/thumbnails/87.jpg)
Calculation rules for random variables
Example 8
What is Y = Total passenger weight?
Y = ∑55i=1 Xi, where Xi ∼ N(70,102) (and assumed to be independent)
Mean and variance of Y:
E(Y) =55
∑i=1
E(Xi) =55
∑i=1
70 = 55 ·70 = 3850
Var(Y) =55
∑i=1
Var(Xi) =55
∑i=1
100 = 55 ·100 = 5500
Y is normal distributed, so we may find P(Y > 4000) using:
1-pnorm(4000, mean = 3850, sd = sqrt(5500))
[1] 0.022
Andreas Baum (DTU Compute) Introduction to Statistics Spring 2022 47 / 49
![Page 88: Course 02402 Introduction to Statistics Lecture 3: Random](https://reader030.vdocuments.us/reader030/viewer/2022021408/6209b0641ea8160b220fa197/html5/thumbnails/88.jpg)
Calculation rules for random variables
Example 8
What is Y = Total passenger weight?
Y = ∑55i=1 Xi, where Xi ∼ N(70,102) (and assumed to be independent)
Mean and variance of Y:
E(Y) =55
∑i=1
E(Xi) =55
∑i=1
70 = 55 ·70 = 3850
Var(Y) =55
∑i=1
Var(Xi) =55
∑i=1
100 = 55 ·100 = 5500
Y is normal distributed, so we may find P(Y > 4000) using:
1-pnorm(4000, mean = 3850, sd = sqrt(5500))
[1] 0.022
Andreas Baum (DTU Compute) Introduction to Statistics Spring 2022 47 / 49
![Page 89: Course 02402 Introduction to Statistics Lecture 3: Random](https://reader030.vdocuments.us/reader030/viewer/2022021408/6209b0641ea8160b220fa197/html5/thumbnails/89.jpg)
Calculation rules for random variables
Example 8 - WRONG ANALYSIS
What is Y?
Definitely NOT: Y = 55 ·X
Mean and variance of WRONG Y:
E(Y) = 55 ·70 = 3850
Var(Y) = 552Var(X) = 552 ·100 = 5502
Wrong Y is also normal distributed. Finding P(Y > 4000) using WRONG Y:
1 - pnorm(4000, mean = 3850, sd = 550)
[1] 0.39
Consequence of wrong calculation:
A LOT of wasted money for the airline company!!!
Andreas Baum (DTU Compute) Introduction to Statistics Spring 2022 48 / 49
![Page 90: Course 02402 Introduction to Statistics Lecture 3: Random](https://reader030.vdocuments.us/reader030/viewer/2022021408/6209b0641ea8160b220fa197/html5/thumbnails/90.jpg)
Calculation rules for random variables
Example 8 - WRONG ANALYSIS
What is Y?
Definitely NOT: Y = 55 ·X
Mean and variance of WRONG Y:
E(Y) = 55 ·70 = 3850
Var(Y) = 552Var(X) = 552 ·100 = 5502
Wrong Y is also normal distributed. Finding P(Y > 4000) using WRONG Y:
1 - pnorm(4000, mean = 3850, sd = 550)
[1] 0.39
Consequence of wrong calculation:
A LOT of wasted money for the airline company!!!
Andreas Baum (DTU Compute) Introduction to Statistics Spring 2022 48 / 49
![Page 91: Course 02402 Introduction to Statistics Lecture 3: Random](https://reader030.vdocuments.us/reader030/viewer/2022021408/6209b0641ea8160b220fa197/html5/thumbnails/91.jpg)
Calculation rules for random variables
Example 8 - WRONG ANALYSIS
What is Y?
Definitely NOT: Y = 55 ·X
Mean and variance of WRONG Y:
E(Y) = 55 ·70 = 3850
Var(Y) = 552Var(X) = 552 ·100 = 5502
Wrong Y is also normal distributed. Finding P(Y > 4000) using WRONG Y:
1 - pnorm(4000, mean = 3850, sd = 550)
[1] 0.39
Consequence of wrong calculation:
A LOT of wasted money for the airline company!!!
Andreas Baum (DTU Compute) Introduction to Statistics Spring 2022 48 / 49
![Page 92: Course 02402 Introduction to Statistics Lecture 3: Random](https://reader030.vdocuments.us/reader030/viewer/2022021408/6209b0641ea8160b220fa197/html5/thumbnails/92.jpg)
Calculation rules for random variables
Example 8 - WRONG ANALYSIS
What is Y?
Definitely NOT: Y = 55 ·X
Mean and variance of WRONG Y:
E(Y) = 55 ·70 = 3850
Var(Y) = 552Var(X) = 552 ·100 = 5502
Wrong Y is also normal distributed. Finding P(Y > 4000) using WRONG Y:
1 - pnorm(4000, mean = 3850, sd = 550)
[1] 0.39
Consequence of wrong calculation:
A LOT of wasted money for the airline company!!!
Andreas Baum (DTU Compute) Introduction to Statistics Spring 2022 48 / 49
![Page 93: Course 02402 Introduction to Statistics Lecture 3: Random](https://reader030.vdocuments.us/reader030/viewer/2022021408/6209b0641ea8160b220fa197/html5/thumbnails/93.jpg)
Calculation rules for random variables
Overview
1 Continuous random variables and distributionsDensity and distribution functionsMean, variance, and covariance
2 Specific continuous distributionsThe uniform distributionThe normal distributionThe log-normal distributionThe exponential distribution
3 Calculation rules for random variables
Andreas Baum (DTU Compute) Introduction to Statistics Spring 2022 49 / 49