# Have a normal distribution with standard deviation x

• Homework Help
• 28
• 94% (52) 49 out of 52 people found this document helpful

This preview shows page 8 - 12 out of 28 pages.

have a normal distribution with standard deviation x n . That’s an even bigger claim than the first one! The proof of the theorem is beyond the scope of this class, but in this exercise, we will be exploring some data to see the CLT in action. 8
</div> Question 1. Define the function one_statistic_prop_heads which should return exactly one simulated statistic of the proportion of heads from n coin flips.
In [20]: ok . grade( "q2_1" ); ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Running tests --------------------------------------------------------------------- Test summary Passed: 1 Failed: 0 [ooooooooook] 100.0% passed 9
</div> Question 2. The CLT only applies when sample sizes are "sufficiently large." This isn’t a very precise statement. Is 10 large? How about 50? The truth is that it depends both on the original population distribution and just how "normal" you want the result to look. Let’s use a simulation to get a feel for how the distribution of the sample mean changes as sample size goes up. Consider a coin flip. If we say Heads is 1 and Tails is 0, then there’s a 50% chance of getting a 1 and a 50% chance of getting a 0, which definitely doesn’t match our definition of a normal distribution. The average of several coin tosses, where Heads is 1 and Tails is 0, is equal to the proportion of heads in those coin tosses (which is equivalent to the mean value of the coin tosses), so the CLT should hold true if we compute the sample proportion of heads many times. Write a function called sample_size_n that takes in a sample size n . It should return an array that contains 5000 sample proportions of heads, each from n coin flips.
10
</div> The code below will use the function you just defined to plot the empirical distribu- tion of the sample mean for various sample sizes. Drag the slider or click on the number to the right to type in a sample size of your choice. The x- and y-scales are kept the same to facilitate comparisons. Notice the shape of the graph as the sample size increases and decreases. In [22]: # Just run this cell from ipywidgets import interact def outer (f): def graph (x): bins = np . arange( -0.01 , 1.05 , 0.02 ) sample_props = f(x) Table() . with_column( ' Sample Size: {} ' . format(x), sample_props) . hist(bins = bins) plt . ylim( 0 , 30 ) print ( ' Sample SD: ' , np . std(sample_props)) plt . show() return graph interact(outer(sample_size_n), x = ( 0 , 400 , 1 ), continuous_update = False ); # Min sample size is 0, max is 400 # The graph will refresh a few times when you drag the slider around interactive(children=(IntSlider(value=200, description= ' x ' , max=400), Output()), _dom_classes=( You can see that even the means of samples of 10 items follow a roughly bell-shaped distribu- tion. A sample of 50 items looks quite bell-shaped.