Suppose that you have three fair 6-sided dice that you roll and then count the total. Estimate the mean total if you were to roll the dice over and over by simulating 250,000 rolls and computing the average of the random outcomes. (In Python)
Python code with comments
The code in text format
----------
import numpy as np
#Define the number of rolls
R=250000
#simulate R rolls of 3 dice each, making this a matrix of 3xR
x=np.random.randint(low=1,high=6+1,size=(3,R))
#get the R column sums, which is the total of 3 dice
s=x.sum(0)
#compute the average of these R totals
m=np.mean(s)
print('The estimated mean total of rolling 3 dice is %.4f'%m)
------
Get Answers For Free
Most questions answered within 1 hours.