# Question 4 use your function from above to simulate

• Homework Help
• 23
• 97% (29) 28 out of 29 people found this document helpful

This preview shows page 16 - 21 out of 23 pages.

Question 4 Use your function from above to simulate the flipping of 10 coins 5000 times under the proportions that you specified in problem 1. Keep track of all of your statistics in coin_statistics . 16
: coin_statistics = make_array() repetitions = 5000 for i in np . arange(repetitions): coin_statistics = np . append(coin_statistics, , coin_simulation_and_statistic( 10 ,coin_statistics)) coin_statistics , --------------------------------------------------------------------------- ValueError Traceback (most recent call , last) <ipython-input-40-719388a4ce5d> in <module> 3 4 for i in np.arange(repetitions): ----> 5 coin_statistics = np.append(coin_statistics, , coin_simulation_and_statistic(10,coin_statistics)) 6 7 coin_statistics <ipython-input-38-a2b57069784d> in , coin_simulation_and_statistic(sample_size, model_proportions) 1 def coin_simulation_and_statistic(sample_size, model_proportions): ----> 2 return sample_proportions(sample_size, model_proportions). , item(0)*sample_size 3 return coin_simulation_and_statistic 4 5 ~/anaconda3/envs/ids/lib/python3.7/site-packages/datascience/util.py in , sample_proportions(sample_size, probabilities) 127 An array with the same length as ``probability`` that sums , to 1. 128 """ --> 129 return np.random.multinomial(sample_size, probabilities) / , sample_size 130 131 mtrand.pyx in numpy.random.mtrand.RandomState.multinomial() 17
ValueError: sum(pvals[:-1]) > 1.0 [ ]: _ = ok . grade( 'q5_4' ) Let’s take a look at the distribution of statistics, using a histogram. [ ]: #Draw a distribution of statistics Table() . with_column( 'Coin Statistics' , coin_statistics) . hist() Question 5 Given your observed value, do you believe that Gary’s model is reasonable, or is our alternative more likely? Explain your answer using the distribution drawn in the previous problem.
• • • 