Question 13 write a python function called it should

• Lab Report
• 9
• 95% (157) 149 out of 157 people found this document helpful

This preview shows page 1 - 6 out of 9 pages.

Question 1.3 Write a Python function called simulate_observations . It should take no arguments, and it should return an array of 7 numbers. Each of the numbers should be the modified roll from one simulation. Then , call your function once to compute an array of 7 simulated modified rolls. Name that array observations On a modified roll of 20, Alice's action succeeded. .
In : modifier = 11 num_observations = 7 def simulate_observations(): """Produces an array of 7 simulated modified die rolls""" return np.random.choice(possible_rolls, num_observations) + modifier #SOLUTION observations = simulate_observations() #SOLUTION observations In [ ]: _ = ok.grade('q1_3') Question 1.4 Draw a histogram to display the probability distribution of the modified rolls we might see. Check with a neighbor or a TA to make sure you have the right histogram. In : # We suggest using these bins. . Out: array([16, 28, 18, 14, 27, 25, 23])
Question 1.5 Using that method, estimate modifier from observations . Name your estimate min_estimate . .
Question 1.6 Figure out a good estimate based on that quantity. Then , write a function named mean_based_estimator that computes your estimate. It should take an array of modified rolls (like the array observations ) as its argument and return an estimate of modifier based on those numbers. In [ ]: def mean_based_estimator(nums): """Estimate the roll modifier based on observed modified rolls in the array nums.""" return np.mean(nums) - 10 #SOLUTION # Here is an example call to your function. It computes an estimate # of the modifier from our 7 observations.
In [ ]: _ = ok.grade('q1_6')
2. Sampling Run the cell below to load the player and salary data. These two datasets also appear in Homework 4.
In : player_data = Table().read_table("player_data.csv") salary_data = Table().read_table("salary_data.csv") full_data = salary_data.join("PlayerName", player_data, "Name") # The show method immediately displays the contents of a table. # This way, we can display the top of two tables using a single cell. player_data.show(3) salary_data.show(3) full_data.show(3)
PlayerName Salary Age Team Games Rebounds Assists Steals Blocks Turnovers Points A.J. Price 62552 28 TOT 26 32 46 7 0 14 133 Aaron Brooks 1145685 30 CHI 82 166 261 54 15 157 954 Aaron Gordon 3992040 19 ORL 47 169 33 21 22 38 243 ... (489 rows omitted) Rather than getting data on every player, imagine that we had gotten data on only a smaller subset of the players. For 492 players, it's not so unreasonable to expect to see all the data, but usually we aren't so lucky. Instead, we often make statistical inferences
• • • 