Skip to content

Commit db54c02

Browse files
authored
Update Binomial_Simulation_input.py
1 parent c2c9edd commit db54c02

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

test/Binomial_Simulation_input.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,17 +2,20 @@
22
import matplotlib.pyplot as plt
33
import seaborn as sns
44
from scipy.stats import binom
5+
from math import floor
56

67
n = int(input("Please enter n(int): "))
78
p = float(input("Please enter p(float): "))
89
size = int(input("Please enter size(int): "))
910
target = int(input("Please enter target(int): "))
1011
mean, var, skew, kurt = binom.stats(n, p, moments='mvsk')
12+
fixed_mean = floor((n+1)*p)
1113
print("Mean:", mean)
14+
print("fixed mean:", fixed_mean)
1215
print("Probability of "+str(target)+":", binom.pmf(target, n, p)*100)
16+
plt.figure(1)
1317
sns.displot(random.binomial(n=n, p=p, size=size))
1418
plt.title("Binomial Simulation w/ n = "+str(n)+", p = "+str(p))
1519
plt.tight_layout()
16-
plt.savefig('plot.png',dpi=300)
17-
plt.show()
18-
plt.close('all')
20+
plt.savefig('plot.png')
21+
# plt.show()

0 commit comments

Comments
 (0)