In [1]:
using Plots
using Distributions
INFO: Initializing package repository /mnt/juliabox/.julia/v0.6
INFO: Cloning METADATA from https://github.com/JuliaLang/METADATA.jl

Roll one die 50 times

In [2]:
Y=rand(1:6,50)
print(Y)
[4, 4, 3, 1, 2, 6, 2, 5, 5, 5, 2, 6, 3, 2, 6, 6, 2, 2, 3, 1, 4, 5, 4, 3, 2, 2, 6, 1, 5, 4, 4, 5, 4, 4, 6, 2, 6, 4, 1, 6, 5, 5, 3, 5, 3, 4, 3, 5, 4, 6]

Find the point estimate of the mean

In [3]:
mean(Y)
Out[3]:
3.82

Repeat the two steps above 1000 times, to obtain a random sample (n=1000) from the distribution of the estimator: $\bar{X}_n$ (i.e. a collection of 1000 point estimates)

In [4]:
X=[mean(rand(1:6,50)) for i in 1:1000];

Observe that the distribution of these point estimates resembles the normal distribution (bell curve)

In [5]:
gr()
histogram(X)
Out[5]:
2.8 3.0 3.2 3.4 3.6 3.8 4.0 4.2 0 50 100 150 y1