Question: Write a function simulate_dice_rolls which takes in two params, num_rolls and iterations. It should return a 1-D Numpy array of length iterations, where each item

Write a function simulate_dice_rolls which takes in two params, num_rolls and iterations. It should return a 1-D Numpy array of length iterations, where each item is the sum of throwing a fair 6-sided die num_rolls times. It should also automatically output a histogram of the rolls to the file dice_{0}_rolls_{1}.png, where {0} is num_rolls and {1} is iterations. (No need for any labels, title, legends, etc.)

Run your function for num_rolls = 5 and iterations = 2000 and paste the plot here.

For this assignment, you should not use loops! You should be using vectorized operations. Functional iterators are also not allowed.

The following operations will be deducted: for, while, comprehensions (like [x for x in range(10)], map(), and filter().

Use python 3.8. Thanks!

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!