Question 4 use your function from above to simulate

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
[40]: 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.
1.6 6. Submission Once you’re finished, select “Save and Checkpoint” in the File menu and then execute the submit cell below. The result will contain a link that you can use to check that your assignment has been submitted successfully. If you submit more than once before the deadline, we will only grade your final submission. If you mistakenly submit the wrong one, you can head to okpy.org and flag the correct version. To do so, go to the website, click on this assignment, and find the version you would like to have graded. There should be an option to flag that submission for grading! [41]: _ = ok . submit() <IPython.core.display.Javascript object> <IPython.core.display.Javascript object> Saving notebook… Saved 'hw06.ipynb'. Submit… 100% complete Submission successful for user: [email protected] URL: [42]: # For your convenience, you can run this cell to run all the tests at once! import os print ( "Running all tests..." ) _ = [ok . grade(q[: -3 ]) for q in os . listdir( "tests" ) if q . startswith( 'q' )] print ( "Finished running all tests." ) Running all tests… ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Running tests 18
--------------------------------------------------------------------- Test summary Passed: 1 Failed: 0 [ooooooooook] 100.0% passed ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Running tests --------------------------------------------------------------------- Test summary Passed: 1 Failed: 0 [ooooooooook] 100.0% passed ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Running tests --------------------------------------------------------------------- Test summary Passed: 1 Failed: 0 [ooooooooook] 100.0% passed ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Running tests --------------------------------------------------------------------- Test summary Passed: 1 Failed: 0 [ooooooooook] 100.0% passed ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Running tests --------------------------------------------------------------------- Test summary Passed: 1 Failed: 0 [ooooooooook] 100.0% passed ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Running tests --------------------------------------------------------------------- Question 4_6 > Suite 1 > Case 1 19
>>> # It looks like your other_statistic array is empty!

  • Left Quote Icon

    Student Picture

  • Left Quote Icon

    Student Picture

  • Left Quote Icon

    Student Picture