Homework 6: Probability, Simulation, Estimation, and
Assessing Models
Reading:
Randomness (https://www.inferentialthinking.com/chapters/09/randomness.html)
Sampling and Empirical Distributions (https://www.inferentia
...
Homework 6: Probability, Simulation, Estimation, and
Assessing Models
Reading:
Randomness (https://www.inferentialthinking.com/chapters/09/randomness.html)
Sampling and Empirical Distributions (https://www.inferentialthinking.com/chapters/10/sampling-andempirical-distributions.html)
Testing Hypotheses (https://www.inferentialthinking.com/chapters/11/testing-hypotheses.html)
1. Probability
We will be testing some probability concepts that were introduced in lecture. For all of the following problems,
we will introduce a problem statement and give you a proposed answer. Next, for each of the following
questions, you must assign the provided variable to one of three integers. You are more than welcome to
create more cells across this notebook to use for arithmetic operations, but be sure to assign the provided
variable to 1, 2, or 3 in the end.
1. Assign the variable to 1 if you believe our proposed answer is too low.
2. Assign the variable to 2 if you believe our proposed answer is correct.
3. Assign the variable to 3 if you believe our proposed answer is too high.
Question 1. You roll a 6-sided die 10 times. What is the chance of getting 10 sixes?
Our proposed answer:
Assign ten_sixes to either 1, 2, or 3 depending on if you think our answer is too low, correct, or too high.
( 1
6
)10
=====================================================================
Assignment: Homework 6: Probability, Simulation, Estimation, and Asses
sing Models
OK, version v1.12.5
=====================================================================
Successfully logged in as
[email protected]
# Don't change this cell; just run it.
import numpy as np
from datascience import *
# These lines do some fancy plotting magic.
import matplotlib
%matplotlib inline
import matplotlib.pyplot as plt
plt.style.use('fivethirtyeight')
import warnings
warnings.simplefilter('ignore', FutureWarning)
from client.api.notebook import Notebook
ok = Notebook('hw06.ok')
_ = ok.auth(inline=True)In [2]:
In [3]:
Question 2. Take the same problem set-up as before, rolling a fair dice 10 times. What is the chance that every
roll is less than or equal to 5?
Our proposed answer:
Assign five_or_less to either 1, 2, or 3.
1 − ( 1
6
)10
In [5]:
Out[2]:
2
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Running tests
---------------------------------------------------------------------
Test summary
Passed: 1
Failed: 0
[ooooooooook] 100.0% passed
Out[5]:
3
ten_sixes = 2
ten_sixes
_ = ok.grade('q1_1')
five_or_less = 3
five_or_lessIn [6]:
Question 3. Assume we are picking a lottery ticket. We must choose three distinct numbers from 1 to 100 and
write them on a ticket. Next, someone picks three numbers one by one, each time without putting the previous
number back in. We win if our numbers are all called.
If we decide to play the game and pick our numbers as 12, 14, and 89, what is the chance that we win?
Our proposed answer:
Assign lottery to either 1, 2, or 3.
( 3
100
)3
In [8]:
In [9]:
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Running tests
---------------------------------------------------------------------
Test summary
Passed: 1
Failed: 0
[ooooooooook] 100.0% passed
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Running tests
---------------------------------------------------------------------
Test summary
Passed: 1
Failed: 0
[ooooooooook] 100.0% passed
_ = ok.grade('q1_2')
lottery = 3
_ = ok.grade('q1_3')Question 4. Assume we have two lists, list A and list B. List A contains the numbers [10,20,30], while list B
contains the numbers [10,20,30,40]. We choose one number from list A randomly and one number from list B
randomly. What is the chance that the number we drew from list A is larger than the number we drew from list
B?
Our proposed solution:
Assign list_chances to either 1, 2, or 3.
1/4
In [10]:
In [11]:
2. Monkeys Typing Shakespeare
(...or at least the string "datascience")
A monkey is banging repeatedly on the keys of a typewriter. Each time, the monkey is equally likely to hit any of
the 26 lowercase letters of the English alphabet, regardless of what it has hit before. There are no other keys on
the keyboard.
Question 1. Suppose the monkey hits the keyboard 11 times. Compute the chance that the monkey types the
sequence datascience . (Call this datascience_chance .) Use algebra and type in an arithmetic
equation that Python can evalute.
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Running tests
---------------------------------------------------------------------
Test summary
Passed: 1
Failed: 0
[ooooooooook] 100.0% passed
list_chances = 1
_ = ok.grade('q1_4')In [12]:
[Show More]