Is it possible to get scipy.stats.binom.pmf(x, n, p) to return the number of trials (n) with the probabaility, number of successes (x), and probability of successes (p) known?
Example Problem:
How many throws does Alex need to do in order to be 90% sure of hitting the target at least 10 times?
where:
- Probability = 0.90
- p = 0.50
- x = 10
You can do something like this. What you want to compute is what
scipy.statscalls the survival function (sf) which is1-cdf. Since you are interested in greater than or equal to 10 success--that is the sum of the probabilities of 10 or more successes, that is precisely1-cdf. Thesffunction can take a numpy array for the arguments, so we pass in an array forn(varying the number of trials). We then look for the number of trials that gave us a value greater than the definedconfidence.The plot is not necessary for the computation, but allows us to verify that the procedure does give us the correct answer.