Plot the empirical distribution functions (based on \(10^4\) random variables) for \(Z_{10}\), \(Z_{100}\) and \(Z_{1000}\). On the same figure plot the distribution function of the standard normal random variable.
import matplotlib.pyplot as plt import random from random import seed from statistics import * from scipy.stats import norm
defz_n_calc(n): root_n = pow(n, 0.5) seed() num_array = [random.uniform(0,1) for _ inrange(n)] expectation = sum(num_array)/n stdeviation = stdev(num_array) res = 0 for i inrange(0, n): res = res + (num_array[i]-expectation)/(stdeviation*root_n)
return res
defsample_generator(n): return [z_n_calc(n) for _ inrange(10000)]
defnorm_cdf_generator(array_in): return [norm.cdf(x) for x in array_in] y_array = [x/10000.0for x inrange(10000)]