Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/usr/bin/env python
- import math
- import matplotlib.pyplot as plt
- import numpy as np
- from scipy.interpolate import spline
- n = 60 # число открытых бочек
- p = 0.05 # вероятность выпадения леги
- q = 1 - p
- K = np.array([])
- P = np.array([])
- for k in range(0, 11):
- Pmn = math.factorial(n) / (math.factorial(k) * math.factorial(n-k)) * math.pow(p, k) * math.pow(q, n-k)
- print(k, round(Pmn * 100, 3), "%")
- K = np.append(K, k)
- P = np.append(P, round(Pmn * 100, 3))
- fig, ax = plt.subplots()
- Knew = np.linspace(K.min(), K.max(), 100)
- Psmooth = spline(K,P,Knew)
- ax.plot(Knew, Psmooth, lw=2, c="red")
- ax.plot(K, P, lw=0, c="red", aa=True, marker="o", ms=8)
- for i, txt in enumerate(P):
- ax.annotate(txt, (K[i],P[i]))
- ax.grid(True)
- fig.autofmt_xdate()
- plt.xticks(K)
- plt.title("The chance to get a few Legendaries from 60 barrels")
- plt.xlabel("The number of Legendaries")
- plt.ylabel("%")
- #plt.show()
- fig.set_size_inches(16, 10)
- plt.savefig("bernulli_60_barrels.png", format='png', dpi=150)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement