# Failed 0 ooooooooook 1000 passed saving notebook

• 25
• 100% (2) 2 out of 2 people found this document helpful

This preview shows page 12 - 16 out of 25 pages.

Failed: 0 [ooooooooook] 100.0% passed Saving notebook... Saved 'hw09.ipynb'. Backup... 100% complete Backup successful for user: [email protected] URL: NOTE: this is only a backup. To submit your assignment, use: python3 ok --submit
10/31/2018 hw09 Question 5: Do our predicted and empirical values match? Why is this the case? Hint: Are there any laws that we learned about in class that might help explain this?
13/25 3. Polling and the Normal Distribution Question 1 Michelle is a statistical consultant, and she works for a group that supports Proposition 68 (which would mandate labeling of all horizontal or vertical axes), called Yes on 68. They want to know how many Californians will vote for the proposition. Michelle polls a uniform random sample of all California voters, and she finds that 210 of the 400 sampled voters will vote in favor of the proposition. Fill in the code below to form a table with 3 columns: the first two columns should be identical to sample . The third column should be named Proportion and have the proportion of total voters that chose each option. In [26]: sample = Table() . with_columns( "Vote" , make_array( "Yes" , "No" ), "Count" , make_array( 210 , 190 )) sample_size = 400 sample_with_proportions = sample . with_column( 'Proportion' , sample . column( 'Coun t' ) / sample_size) sample_with_proportions Out[26]: Vote Count Proportion Yes 210 0.525 No 190 0.475
10/31/2018 hw09 14/25 In [27]: _ = ok . grade( 'q3_1' ) _ = ok . backup() Question 2 She then wants to use 10,000 bootstrap resamples to compute a confidence interval for the proportion of all California voters who will vote Yes. Fill in the next cell to simulate an empirical distribution of Yes proportions with 10,000 resamples. In other words, use bootstrap resampling to simulate 10,000 election outcomes, and populate resample_yes_proportions with the yes proportion of each bootstrap resample. Then, visualize resample_yes_proportions with a histogram. You should see a bell shaped curve centered near the proportion of Yes in the original sample. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Running tests --------------------------------------------------------------------- Test summary Passed: 1 Failed: 0 [ooooooooook] 100.0% passed Saving notebook... Saved 'hw09.ipynb'. Backup... 100% complete Backup successful for user: [email protected] URL: NOTE: this is only a backup. To submit your assignment, use: python3 ok --submit
10/31/2018 hw09 15/25 In [28]: resample_yes_proportions = make_array() for i in np . arange( 10000 ): resample = proportions_from_distribution(sample_with_proportions, "Proport ion" , sample_size) resample_yes_proportions = np . append(resample_yes_proportions, resample . co lumn(