0% found this document useful (0 votes)
21 views2 pages

Exercises 3 Simulations

Uploaded by

lissstudiesf19
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
21 views2 pages

Exercises 3 Simulations

Uploaded by

lissstudiesf19
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 2

Computer Statistics 3.

Simulations Exercises

Note on notation: by N (µ, σ 2 ), we denote normal distribution with parameters µ (mean) and
σ 2 (variance).

Ex.3.1. Let X ∼ N (1, 4). Use R to:


(a) find fX (0), where f denotes probability density function, or pdf.
(b) find FX (5), where F denotes cumulative distribution function, or cdf.
(c) compute P (X > 2.5), P (1 <= X <= 4).
(d) find x such that P (X ≤ x) = 0.9.
(e) Install package mosaic and use xpnorm() and xqnorm() functions to solve tasks (b) -
(d).

Ex.3.2. Plot pdf and cdf of the following distributions:

N (0, 1), N (0, 4), N (0, 9), N (1, 1), N (2, 1), N (3, 1).

All pdf curves should be drew in one plot, and the cdf curves should be in another plot. The
pdf plot should be placed above cdf plot. Add legend.

Ex.3.3. Plot (in one plot) the following densities: N (0, 1), t1 , t2 , t10 , t100 , where tv denotes
Student’s t-distribution with v degrees of freedom.

Ex.3.4. In the build-in data set airquality there is a variable Temp. Check (graphically) if
this variable comes from normal distribution.

Ex.3.5. Plot the pmf of the following distributions:


(a) Bin(10, 0.3)
(b) P ois(2)

Ex.3.6. A fair coin is tossed 4 times.


(a) What is the probability of getting exactly 2 heads?
(b) What is the probability of getting at most 2 heads?
(c) What is the probability of getting at least 2 heads?
(d) Verify results using directly the pmf formula (i.e. without using dbinom() and pbinom()
functions).

Ex.3.7. Let U1 , U2 , U3 ∼ U[0, 1] and they are independent. Let S = U1 + U2 + U3 .


(a) Approximate P(SPn < 1.5) and compare it with the true value, knowing that random
variable Sn = i=1 Ui , where Ui ∼ U[0, 1] and are independent, i = 1, . . . , n, follows
Irwin-Hall distribution for which cumulative distribution function is given by
⌊x⌋  
X
k n
FSn (x) = 1
n!
(−1) (x − k)n , x ∈ [0, n].
k=0
k

(b) Plot cumulative fractions to see how fast the approximates convergence to the true
value. Check results for some high number of samples, e.g. 104 .
Computer Statistics 3. Simulations, Page 2 of 2 Exercises

Ex.3.8. Let X1 , . . . , Xn be a simple random sample from N (2, 9) and n = 103 .


(a) Generate one realization x1 , . . . , xn of this sample.
i. Compute sample quantiles 0.25 and 0.75 and compare it with theoretical quantiles
of the sampling distribution.
ii. Plot histogram of x1 , . . . , xn and pdf of the sampling distribution in one plot.
iii. Plot empirical cdf and cdf of the sampling distribution in one plot.
iv. (Illustration of the Strong Law of Large Numbers) Approximate E(X1 ) using MC
simulationPstudy, and compare it with the true value 2. Plot cumulative means
m(j) = 1j ji=1 xi , j ∈ {1, . . . , n} to see how fast the approximates converge to the
true value. Check results for some high values of n, e.g. n = 106 .
v. Follow the instructions from point iv. to estimate Var(X1 ).
(b) (Illustration of the Central Limit Theorem) Generate r = 104 realizations of this sample.
i. For each realization xk1 , . . . , xkn , k = 1, . . . , r, compute sample mean mk = n1 ni=1 xki .
P

That is we have r realizations of X.


ii. Plot (one plot): histogram of

m1 − EX1 mr − EX1
q , ..., q
Var(X1 ) Var(X1 )
n n

and pdf of wisely chosen normal distribution.


(c) Repeat all above tasks for a sample from Exp(2).
i.i.d. 2
Ex.3.9. Let X, Y ∼ N (0, σ2 ).
Var[(X+Y )2 ]
(a) Prove that Var(X 2 ) = 4
.
(b) Demonstrate that the above formula holds true using MC simulation study for σ ∈
{1, 2 . . . , 200} by creating a plot where x-axis - σ, y-axis - MC approximations of
)2 ]
Var(X 2 ) − Var[(X+Y4
.

Ex.3.10. Let X ∼ N (0, σ 2 ).


(a) Prove that E(X 4 ) = 3σ 4 .
(b) Verify the result obtained using MC simulation study for σ ∈ {1, 2 . . . , 200} by creating
a plot where x-axis - σ, y-axis - MC approximations of E(X 4 ).
(c) Plot approximations for σ = 30 and σ = 50 (two graphs on one plot) to see the
differences in convergence of the approximates to the true value.

Last updated: 2023-12-20

You might also like