Question: I need help with Question 3.2 HHT_emp_prob Data Science, Python Jupyter Notebook import numpy as np import math from datascience import * # These lines
I need help with Question 3.2 HHT_emp_prob
Data Science, Python Jupyter Notebook
import numpy as np import math from datascience import *
# These lines set up the plotting functionality and formatting. import matplotlib matplotlib.use('Agg', warn=False) %matplotlib inline import matplotlib.pyplot as plots plots.style.use('fivethirtyeight')


It's something like
empirical_P = np.count_nonzero(sampled_stats >= observed_statistic)/repetitions
In [41]: def generate flips): Heads (H) is 1 and ToiLS (T) ts e WHHT means 1186 in decimaL WHTT means 1894 in decimaL while(True): cnp.randon.randint (1, 8) return "HHT if(c4): return "HTT return generateflips() Out [41]:HHT In [42]: _- ok.grade( q3e) Running tests Test sunnary Passed:1 Failed:e [ooooooooook] 100.0% passed Question 3.1 Now that we can generate coin flip sequences until getting HHT or HTT, we want to generate such coin fip sequences many times. Simulate 10,000 coin toss sequences until one of HHT or HTT occurs, and record which pattern occured first in a table called coinflips that contains a single column called pattern. Each entry in the pattern column should be either HHT or HTT, whichever appeared first. In [S1]: simulate -nake_array) for i in np.arange (1888e): simulate np.append (sinulate, generate flips)) coin flips Table().with_column('pattern',simulate) coin flips Out [51]: pattrn HTT HTT HHT HTT HHT HTT In [41]: def generate flips): Heads (H) is 1 and ToiLS (T) ts e WHHT means 1186 in decimaL WHTT means 1894 in decimaL while(True): cnp.randon.randint (1, 8) return "HHT if(c4): return "HTT return generateflips() Out [41]:HHT In [42]: _- ok.grade( q3e) Running tests Test sunnary Passed:1 Failed:e [ooooooooook] 100.0% passed Question 3.1 Now that we can generate coin flip sequences until getting HHT or HTT, we want to generate such coin fip sequences many times. Simulate 10,000 coin toss sequences until one of HHT or HTT occurs, and record which pattern occured first in a table called coinflips that contains a single column called pattern. Each entry in the pattern column should be either HHT or HTT, whichever appeared first. In [S1]: simulate -nake_array) for i in np.arange (1888e): simulate np.append (sinulate, generate flips)) coin flips Table().with_column('pattern',simulate) coin flips Out [51]: pattrn HTT HTT HHT HTT HHT HTT
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
