karlakmkj

Probability - Random variables

Jul 21st, 2021 (edited)
139
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.55 KB | None | 0 0
  1. import numpy as np
  2.  
  3. '''
  4. in the format: random.choice(a, size = size, replace = True/False)
  5.     a is a list or other object that has values we are sampling from
  6.    size is a number that represents how many values to choose
  7.    replace determines whether we keep a value in a after drawing it (True) or remove it from the pool (False)
  8. '''
  9. # create 6 sided "die"
  10. die_6 = range(1, 7)
  11.  
  12. # set number of rolls
  13. num_rolls = 10
  14.  
  15. # roll the "die" the set amount of times
  16. results_1 = np.random.choice(die_6, size = num_rolls, replace = True)
  17. print(results_1)
Add Comment
Please, Sign In to add comment