mean_1 = sample_distribution(1, "means_1.png") print(mean_1) mean_2 = sample_distribution(2, "means_2.png") print(mean_2) mean_5 = sample_distribution(5, "means_5.png") print(mean_5) mean_10 = sample_distribution(10, "means_10.png") print(mean_10) mean_20 = sample_distribution(20, "means_20.png") print(mean_20) mean_30 = sample_distribution(30, "means_30.png") print(mean_30) mean_40 = sample_distribution(40, "means_40.png") print(mean_40) mean_50 = sample_distribution(50, "means_50.png") print(mean_50)
Please note that we can also verify that the population is not normally distributed by using the following code:
s = [random.randint(1, 6) for _ in range(100000)]
pyplot.hist(s)
pyplot.savefig("distribution_of_population.png")
And in this case, the distribution of the population will be like the following:

So, the whole Python code for verifying the Central Limit Theorem is as follows: …








































0 Comments