1

Please assist me in the use of cdf (cumulative distribution function) to calculate probability of 2 or less outcomes out of 5 trials; (≤2)=(0)+(1)+(2) p=0.1 , n=5

I tried the following after importing the necessary libraries;

prob1 = stats.binom.cdf(2, 5, 0.1)
prob2 = stats.binom.cdf(1, 5, 0.1)
prob3 = stats.binom.cdf(0, 5, 0.1)
prob1+prob2+prob3
2.5

I figured the above out after plotting;

x = np.arange(0,10,.05)
y = stats.binom.cdf(x,    # probability of k = 5 successes or less
                10,       # with 10 trials
                p)      # success probability 0.8
plt.xlabel('x')
plt.ylabel('Cumulative density, F(x)')
plt.plot(x,y,'g-')

for n=5 p~=0.99 from the plot

and using ;

stats.binom.cdf(2, 5, 0.1)

p=0.99144

  • Does this helps https://stackoverflow.com/questions/9448246/calculating-probability-of-a-random-variable-in-a-distribution-in-python ? – Pygirl Mar 18 '20 at 20:17
  • Thanks, though i need to use with a ...cdf function.. – Hemal Patel Mar 18 '20 at 21:02
  • I revisited the solution and the answ. seem to be; (≤2)=(0)+(1)+(2) ..................stats.binom.cdf(2, 5, 0.1) with p=0.1 , n=5 and x<=2 – Hemal Patel Mar 18 '20 at 21:27

0 Answers0