Answered step by step
Verified Expert Solution
Question
1 Approved Answer
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)/repetitionsIn [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
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started