Calculates the probability of exceeding a given number of hits for a collection of Bernoulli trials, which is a test with a binary result (e.g. yes/no, 1/0, heads/tails). User inputs a vector of probabilities of success for each trial, p, and a number of successes, h, and this function outputs the probability of equaling or exceeding h.
Example:
There is a 30% chance of rain Saturday, and 20% Sunday. What is the
probability that it rains this weekend?
monte_exceedance([.3; .2],1)
ans =
0.4431
Which is reasonably close to the theoretical value of .44. Increasing the number of runs improves the accuracy:
monte_exceedance([.3; .2],1,100000)
ans =
0.4407
|