2 Python practice via statistical concepts: 10 points. This question helps you brush up on your numerical computing skills in Python by implementing some basic statistics concepts. Let X be a random variable that takes values +1, -1 with equal probability. That is:
P(X = +1) = P(X = -1) = 1/2.
Generate N = 10,000 datasets, each of which has n data points. For this simulation, we consider n = {10, 100, 1000, 10000}. (Hint: Write a function that samples from the uniform distribution between 0 and 1. If the result is less than 0.5, set it to -1. Otherwise, set it to 1). Let Xn be the sample average of the ith dataset; μ = E(X) = 0 and σ^2 = Var(X) = 1. (Hint: Once you compute the sample averages, you will not need the individual data points from each dataset. Therefore, to save memory, you need only store the Xn rather than all the data points. It is highly recommended that you do this to avoid freezing or crashing your computer). Plot and interpret the following:
(a) log10(n) vs. X( ̃μ) (Hint: This plot illustrates how the deviation X, μ converges to 0 as n increases). Draw log10(n) vs. XnI{X( ̃μ) > ε} for ε = 0.5, ε = 0.1, ε = 0.05 (Hint 1: This plot illustrates the convergence of empirical averages to true expectation). (Hint 2: For some statement S, the indicator function I{S} is defined as I{S} = 1 if S is true and I{S} = 0 otherwise). Draw histograms of Vn(X( ̃μ)/σ) for N datasets for n = 10, n = 1,000, n = 10,000. You may choose your histogram bins or let Python choose automatically - any meaningful plot will do (Hint: This plot illustrates the Central Limit Theorem).