SlidesCourse 14 Oct
SlidesCourse 14 Oct
SlidesCourse 14 Oct
# E V
#2.002192 3.780069
#simEV(1.e6)
# E V
#1.999655 3.777565
Example D)
0 for x < 0
X continuous: F(x) = x^2/2 for 0 <= x < 1
x/2 for 1 <= x < 2
1 for 2 <= x
a) Show that F(x) is a CDF and that it is continuous.
b) Guess the value of the expectation of X. Is it larger or smaller than 1 or exactly 1?
c) Calculate the expectation of X.
Solution a: non decreasing is ok as x^2/2 for x>0 ok, x/2 ok, 0 and 1 ok
limit_( x-> - infinity) ok limit to + infinity is 1 as required
right continuous function;
we show continuous: x and x^2 are continuous ==> check x=0 and x=1 and 2 all ok
(comment F is continuous ==> P(X= c) = 0 ie X has no point masses
b) pdf: f(x) = F’(x) = 2x/2 = x for 0<=x<1
1/2 for 1 <= x < 2
0 else
plot of the pdf:
Rcode: plot(xv <- seq(0,2,0.001), ifelse(xv<1,xv,1/2),type="l")
plot shows: E(X) is larger than 1 as values “far from 1“ have larger probability to the right
of 1.
c) “classical mistake” E(X) = integral x F(x) dx NEED pdf to calcuate E(X) !!!!!!!!!
solution:
E(X) = integral_(0,2) x f(x) dx =
= integral_(0,1) x f(x) dx + integral_(1,2) x f(x) dx =
= integral_(0,1) x^2 dx + integral_(1,2) x 0.5 dx = [ x^3/3]_(0,1) + 0.25 [x^2]_(1,2) =
DISCRETE DISTRIBUTIONS
For a sequence of biased coin tosses with prob(1) = prob(head in 1 exper.) = p
= “Bernoulli trials” (sequence of independent 0,1 experiments)
Binomial distribution
X … Total number of successes in n trials parameters: n p
Geometric distribution (Negative Binomial with r=1)
X … Number of trials required till the 1-st success p
Negative Binomial
X … Number of trials required till the r-th success r p
Poisson
X … Total number of successes when n is large, p small and unknown but E(X) is known
Hypergeometric distribution N… number of balls in urn, n trials, r “marked”
Urn experiment without replacement
for N >> n very similar to Binomial
#################
Example A0:
A policeman has the experience that about 10 percent of the car drivers have no license.
A day he stops cars and checks if the driver has a valid driving license.
What is the probability that of 22 stopped cars more than 5 have no license.
Proper notation to solve such probability examples using standard distributions:
1) define a RV t: hat helps to solve the example:
Example A1: A university has 2000 students, 900 of them male and 1100 female. 100 of
them are randomly selected as delegation of the university.
a) What is the probability that the number of male students in the delegation is at least 50?
b) What is the expecation and the standard deviation of the number of male students in
the delegation?
Let us guess the approximate results:
Example 5.A: Use R to show “numerically” for λ= 2.5 that the formula
for E() and Var() of the Poisson distribution is correct.
E(X) = sum_(x from 0 to infinity) x f(x)
pmf of Poisson distribution: dpois(x, lambda=λ)
x <- 0:100
sum(x*dpois(x,lam=2.5)) # E(X) = lam = 2.5
CONTINUOUS DISTRIBUTIONS
Normal: CDF of normal: N(0,1): F(x) = pnorm(x);
general mu and sigma F(x) = pnorm((x-mu)/sigma)
Uniform
Exponential
Gamma = sum of α independent Exponential (for α integer)
Quantile(p) = F-1(p) m=quantile(0.5) … F(m) = 0.5 m auch 50% left and 50% right of m
m is called the median
a=quantile(0.9) F(a) = 0.9
RV X with quantile(0.9) =20 ==> how many percent of X are larger than 20 ? 0.1
X exceeds (is larger than) 20 with probability 0.9
Example A2: The height of 5 years old fur trees is assumed to follow a normal distribution
with mean 4.5 meter and standard deviation 0.4 meter.
a) Find the probability that the height of a random selected tree exceeds 6 meters.
b)Find the probability that the height of a random selected tree does not exceed 4 meters.
c) Find the height that is exceeded with a probability of 2 percent.
X ... height, X ~ N(mu=4.5,sigma=0.4)
a) P(X>6) = 1-F(6) = 1-pnorm((6-4.5)/0.4) = 1-pnorm(3.75) = -pnorm(-3.75) = 8.84e-5
c) P(X > c) = 0.02 ==> P(X<c) = F(c) = 1 - 0.02 = 0.98; c = F-1(0.98)
Z = (X – mu)/sigma E(Z) = E((X – mu)/sigma) = (E(X)-mu)/sigma = 0
V(Z) = V((X – mu)/sigma) = V(X)/sigma2 = sigma2/sigma2 = 1
Z~ N(mu=0,sigma=1)
X = mu + sigma Z ==> to get the quantile c of X we can simply use the quantile of cZ of Z
and transform it with mu + sigma Z to get c = mu + sigma cZ
cZ = qnorm(0.98) = 2.0537 ==> c = 4.5+0.4*qnorm(0.98) = 5.3215
# to find E(X)
integrate(function(x)x*dgamma(x,shape=5,rate=2.5),
0,Inf,rel.tol=1.e-12)
2 with absolute error < 3.3e-13
Example A3: arrivals to a shop follow a Poisson process with rate 20 per hour.
a) What is the probability that in the next 6 minutes no customer arrives.
b) What is the probability that the waiting time for the 30th customer is smaller than one
hour?
c) Find the waiting time for the arrival of the 30th customer that is exceeded with 99% ?
Example A4: The interarrival times to a filling station are assumed to follow independent
exponential random variates with expectation 20 minutes. What is the probability that in
one hour more than 5 customers arrive?
Solution: As the interarrival times are indepedent exponential variates we know that the
events form a Poisson process. So we first have to find the rate of that poisson process.
It is equal to the rate of the interarrival time distribution. E(exponential) = 1/lam =20
==> lam of Poisson process is 1/20 = 0.05 per minute or 0.05*60 = 3 per hour.
Y ... number of customers in one hour Y~Poisson(lam=3)
P(Y>5) = 1-ppois(5,lam=3) 0.08391794
Information Course:
Tuesday Oct 15 at 11.00: PS
Monday Oct 21 at 15.00 ZOOM course (video shared)
Tuesday Oct 22 at 11.00: PS Unit 5
Monday Nov 4 and Tuesday Nov 5 Lecture in class
Midterm exam mid of November
(Date will be announced)