SHARE
TWEET

script

a guest Jul 15th, 2019 67 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. import math
  2. import random
  3.  
  4. rolls=2
  5. num=1000000
  6. low = 740
  7. high = 5180
  8.  
  9.  
  10. def rollingDie():
  11.     total = 0
  12.     for i in range(num):
  13.         trials = []
  14.         for j in range(rolls):
  15.             trials.append(random.randint(low, high)) # adds a trial to the array
  16.         trials.sort(reverse=True) # sorts from greatest to least
  17.         total+=trials[0]/num # adds on the greatest roll. /num for averaging
  18.     return total
  19.  
  20. def avgDist():
  21.     tot=0
  22.     for i in range(num):
  23.         tot+=abs(random.randint(low, high)- random.randint(low, high))/num
  24.     return tot
  25.  
  26. print(rollingDie())
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top