Advertisement
Guest User

Untitled

a guest
Jan 23rd, 2020
1,220
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.29 KB | None | 0 0
  1. import matplotlib.mlab as mlab
  2. import matplotlib.pyplot as plt
  3. from matplotlib.ticker import FormatStrFormatter
  4. import numpy as np
  5. from random import *
  6.  
  7. attemp_counter = []
  8. v_orb_counter = []
  9. desired_num_implicits = 5
  10. sample_size = 100000
  11.  
  12. while(len(attemp_counter) < sample_size):
  13.   success = False
  14.   attempts = 0
  15.   v_orb = 0
  16.   while(not success):
  17.     implicit = 0
  18.     attempts += 1
  19.     while(implicit < desired_num_implicits):
  20.       x = randint(1,4)
  21.       v_orb += 1
  22.       if(x==1):
  23.         implicit += 1
  24.       elif(x==4):
  25.         break
  26.     if (implicit == desired_num_implicits):
  27.       attemp_counter.append(attempts)
  28.       success = True
  29.       v_orb_counter.append(v_orb)
  30.  
  31. print("Average Number Of Attempts: " + str(sum(attemp_counter) / len(attemp_counter)))
  32. print("Average Number Of Vaal Orbs Used: " + str(sum(v_orb_counter) / len(v_orb_counter)))
  33.  
  34. fig, ax = plt.subplots()
  35.  
  36. ax.xaxis.set_major_formatter(FormatStrFormatter('%g'))
  37. ax.xaxis.set_ticks(np.arange(0, 100, 5))
  38.  
  39. attemp_counter.sort()
  40. step = sample_size//4
  41. sequenced_data = [attemp_counter[0:step-1],attemp_counter[step:step*2-1],attemp_counter[step*2:step*3-1],attemp_counter[step*3:step*4-1]]
  42. n, bins, patches = plt.hist(sequenced_data, range(0, 100), density=0, stacked=1, histtype='barstacked')
  43. plt.show()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement