Otherwise gary wins we play the game once and we lose

This preview shows page 21 - 26 out of 26 pages.

Otherwise, Gary wins. We play the game once and we lose, observing 1 head. We are angry and accuse Gary of cheating! Gary is adamant, however, that the coin is fair. Gary's model claims that there is an equal chance of getting heads or tails, but we do not believe him. We believe that the coin is clearly rigged, with heads being less likely than tails.
Question 1 Assign coin_model_probabilities to a two-item array containing the chance of heads as the first element and the chance of tails as the second element under Gary's model. Make sure your values are between 0 and 1. In [134]: In [135]: Out[134]: [0.5, 0.5] ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Running tests --------------------------------------------------------------------- Test summary Passed: 1 Failed: 0 [ooooooooook] 100.0% passed coin_model_probabilities = [ 0.5 , 0.5 ] coin_model_probabilities _ = ok.grade( 'q5_1' )
Question 2 We believe Gary's model is incorrect. In particular, we believe there to be a smaller chance of heads. Which of the following statistics can we use during our simulation to test between the model and our alternative? Assign statistic_choice to the correct answer. 1. The distance (absolute value) between the actual number of heads in 10 flips and the expected number of heads in 10 flips (5) 2. The expected number of heads in 10 flips 3. The actual number of heads we get in 10 flips Question 3 Define the function coin_simulation_and_statistic , which, given a sample size and an array of model proportions (like the one you created in Q1), returns the number of heads in one simulation of flipping the coin under the model specified in model_proportions Hint: Think about how you can use the function sample_proportions 1 coin_simulation_and_statistic( 10 , coin_model_probabilities) . . Out[179]: 1
In [178]: 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 . In [188]: ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Running tests --------------------------------------------------------------------- Test summary Passed: 1 Failed: 0 [ooooooooook] 100.0% passed _ = ok.grade( 'q5_3' ) coin_statistics = make_array() repetitions = 5000
Out[188]: array([6., 6., 6., ..., 1., 7., 5.])
In [189]: Let's take a look at the distribution of statistics, using a histogram. In [190]: 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. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Running tests --------------------------------------------------------------------- Test summary Passed: 1 Failed: 0 [ooooooooook] 100.0% passed _ = ok.grade( 'q5_4' ) #Draw a distribution of statistics Table().with_column( 'Coin Statistics' , coin_statistics).hist()
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

  • Left Quote Icon

    Student Picture

  • Left Quote Icon

    Student Picture

  • Left Quote Icon

    Student Picture