R code used at
VAPMS Selected Applications of Mathematical Statistics, summer semester 2018/2019.
Class 3 (Feb 28 2019)
Illustration of the Central Limit Theorem:
# num_dices - number of dices, N - number of times we are throwing them
clt <- function (N, num_dices)
{
r <- rep (0, N);
for (i in 1:num_dices)
{
r <- r + sample (1:6, N, replace=T);
}
r <- r/num_dices;
hist (r, 100, freq=F, main=num_dices);
x <- seq(min(r), max(r), length=100);
lines (x, Norm(x, sd(r), mean(r)), type="l");
}
for (n in c(1,10,100,1000,10000))
{
clt (1000, n);
Sys.sleep (3);
}
Created: Tue Mar 5 2019
Last modified: Wed Mar 6 01:37:00 CET 2019