import numpy as np
min_num = 1
max_num = 7
num_of_points = 20
random_array = np.random.random_integers(min_num,max_num,num_of_points)
print( random_array )
Just PressRun
.
Dice Roll
You can do this to simulate a dice roll [1,6] and print out how many times you landed on each number.
import numpy as np
min_num = 1
max_num = 7
num_of_points = 2000 # as you increase this the numbers get close and closer to being equal
random_array = np.random.random_integers(min_num,max_num,num_of_points)
result_count = [np.sum(random_array == 1), np.sum(random_array == 2), np.sum(random_array == 3), np.sum(random_array == 4), np.sum(random_array == 5), np.sum(random_array == 6) ]
print( result_count ) # Count of dice rolls
print( [x / num_of_points for x in result_count] ) # Percentage of dice rolls
Just PressRun
.