Guest User

Untitled

a guest
Mar 17th, 2017
82
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.40 KB | None | 0 0
  1. import numpy as np
  2.  
  3. num_tests = 100000
  4.  
  5. choices = range(10)
  6.  
  7. # Let's say choices 0 and 1 are the ones we want.
  8.  
  9. successes = 0
  10.  
  11. for i in range(num_tests):
  12.     draw = np.random.choice(choices, size=3, replace=False)
  13.  
  14.     if 0 in draw or 1 in draw:
  15.         successes += 1
  16.  
  17. print "{} successes out of {} tries, leads to chance of {}".format(successes, num_tests, float(successes) / num_tests)
Add Comment
Please, Sign In to add comment