Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import matplotlib.mlab as mlab
- import matplotlib.pyplot as plt
- from matplotlib.ticker import FormatStrFormatter
- import numpy as np
- from random import *
- attemp_counter = []
- v_orb_counter = []
- desired_num_implicits = 5
- sample_size = 100000
- while(len(attemp_counter) < sample_size):
- success = False
- attempts = 0
- v_orb = 0
- while(not success):
- implicit = 0
- attempts += 1
- while(implicit < desired_num_implicits):
- x = randint(1,4)
- v_orb += 1
- if(x==1):
- implicit += 1
- elif(x==4):
- break
- if (implicit == desired_num_implicits):
- attemp_counter.append(attempts)
- success = True
- v_orb_counter.append(v_orb)
- print("Average Number Of Attempts: " + str(sum(attemp_counter) / len(attemp_counter)))
- print("Average Number Of Vaal Orbs Used: " + str(sum(v_orb_counter) / len(v_orb_counter)))
- fig, ax = plt.subplots()
- ax.xaxis.set_major_formatter(FormatStrFormatter('%g'))
- ax.xaxis.set_ticks(np.arange(0, 100, 5))
- attemp_counter.sort()
- step = sample_size//4
- 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]]
- n, bins, patches = plt.hist(sequenced_data, range(0, 100), density=0, stacked=1, histtype='barstacked')
- plt.show()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement