Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Question 5 and 6 have me stuck because I do not understand what they are asking for, I sent photos of the previous questions code

image text in transcribedimage text in transcribed

Question 5 and 6 have me stuck because I do not understand what they are asking for, I sent photos of the previous questions code to help you get some context. Thank you! Question 4 might not be correct as well.

Simulation Exercise Each move in the game Monopoly is determined by the total number of spots of two rolls of a die. If you play Monopoly, what should you expect to get when you roll the die two times? Question1 Represent roll result as a list of all potential spots of the die then demonstrate a roll of two dices (equivalently two times of a roll of one die) In [27]: import numpy as np In [28]: #dice array die = (1, 2, 3, 4, 5, 6] #write your code here rolli = np.random.choice (die) roll2 = np.random.choice(die) print("Dice 1 Rolled: rolli) print("Dice 2 Rolled: ", rollz) Dice 1 Rolled: 1 Dice 2 Rolled: 4 Question 2: Simulate single move in Monoploly (it is the sum of two dices) In [29]: # one move #Write your code here sum_die = rolli + roll2 sum_die Out[29]: 5 Question 3: Simulate all potential values of each move via 10,688 experiments. Store result into a Pandas DataFrame and display first few rows of the DataFrame In [31]: #Write your code here import pandas as pd roll_dict = {} num_exp = 18000 for i in np.arange(num_exp): rolls = np.random.choice(die, 2) outcome = np.sum(rolls) if outcome in roll_dict.keys(): roll_dict(outcome] += 1 else: roll_dict(outcome) = 1 print(roll_dict) roll_df = pd.DataFrame(list(roll_dict.items()), columns = ['outcome', 'frequency']) roll df.head() {4: 779, 6: 1378, 9: 1106, 7: 1671, 5: 1138, 3: 562, 11: 547, 8: 1373, 12: 296, 10: 841, 2: 317} Out[31]: outcome frequency 4 779 0 1 1 6 1378 2 9 1106 3 7 1671 4 5 1130 Question 4: Plot a histogram using DataFrame function (hist()) to display the distribution of the value per move in Monopoly using default bins. In [18]: #write your code here roll_df.hist() Out[18]: array([[, <title>]], dtype=object) outcome frequency 200 200 175 1.75 150 150 125 125 1.00 1.00 0.75 0.75 0.50 + 050 0.25 0.25 0.00 0.00 500 1000 1500 Question 5: Plot a histogram using Matplotlib library to display the distribution of the value per move in Monopoly using default bins. In [33]: #write your code here roll_df.hist(bins=np.arange() TypeError Traceback (most recent call last) <ipython-input-33-2722d372302b> in <module> 1 #Write your code here ----> 2 roll_df.hist(bins=np.arange) TypeError: arange() missing required argument 'start' (pos 1) Question 6: Choose a custom bins range so that it displays best the frequency of each move value in 10,000 experiments. hint usings range with floating numbers In [37]: #write your code here def custom_bin(df, size, replacement = False): roll_df.sample(size, replace=replacement.hist(bins=np.arange(-20,201,10))) df = pd.DataFrame custom_bin(df,size=18000, replacement= True) NameError Traceback (most recent call last) <ipython-input-37-177ff7465e19> in <module> 3 roll_df sample(size, replace=replacement.hist(bins=np.arange(-20,201,10))) 4 df = pd.DataFrame ----> 5 custom_bin(df,size=10000, replacement= True) NameError: name 'df' is not defined</module></ipython-input-37-177ff7465e19></module></ipython-input-33-2722d372302b>

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Database Principles Programming And Performance

Authors: Patrick O'Neil

1st Edition

1558603921, 978-1558603929

More Books

Students also viewed these Databases questions

Question

What is management growth? What are its factors

Answered: 1 week ago