I am trying to solve a problem involving probabilities.

Suppose there are N1 events and n successes with each success having a probability of p. It is easy to show that the probability of these n events occuring is

N1Cn p^n (1-p)^(N1-n)

What is different about my problem is that rather than varying n I am varying N1.

That is, I want to ask, for example, what range of N1 values can I predict so that I am 95% certain of getting n successes?

As a more specific example, suppose n = 5 and p = 0.3. What is the range of N values which I can be 95% certain that I would get 5 successes? e.g. N = 10 to 30.

As a more specific example, suppose n = 5 and p = 0.3. What is the range of N values which I can be 95% certain that I would get 5 successes? e.g. N = 10 to 30.

You can't. It's impossible. N = n/p = 17 gives you the highest possibility of getting 5 successes and the probability is 20.81%

0

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

N = n/p will always give you the highest probability. Then you can just loop adding one to N until you pass the target probability and do the same thing on the other side subtracting one from the best N.

The compicated mess I posted for finding the range in the other question is a method of using binary search, so it's very fast. But on a modern computer, you could do it the easy way (changing N by 1 every time) and it will still get you the answer quickly enough.

"You can't. It's impossible. N = n/p = 17 gives you the highest possibility of getting 5 successes and the probability is 20.81%"

I think you've misunderstood what I was saying. For example, if I choose N= 10 to 30, it is possible to calculate probabilities for 5 successes. I'm not asking for a specific N to give a 95% probability. Rather I would be attempting to work out the range of values that I could be pretty certain that I the value of N was realistic. For example, the probability of only 5 successes in 1000 trials would be extremely remote.

As such, I'm looking for the most likely range of N's which would give me the best bet.

>> As such, I'm looking for the most likely range of N's which would give me the best bet.

What exactly are the terms of this bet??

0

IssacJonesAuthor Commented:

Hi d-glitch

I don't think your method will work.

In the calculator you mention, n is varied to obtain the 95% i.e. you are keeping N fixed. This is not the same thing I am considering.

Thanks for trying.

0

IssacJonesAuthor Commented:

Hi again tommy

I have written some code which generates all the probabilities for varying N and as we have found they sum to 1/p when N tends to infinity.

What I have then tried to do it multiply the calculated probabilities by p. This means that my new series sums to 1. Do you think I can do the following? iterate through the probabilities until there accumulated sum is 2.5% (store the N value) and then to 97.5 (and store the next N value). This gives me the range of N values.

Do you think this would give me the 95% certainty I'm looking for? There is a niggling doubt at the back of my mind that it isn't quite right.

0

IssacJonesAuthor Commented:

d-glitch -> exactly 5 successes but with N varying.

d-glitch -> exactly 5 successes but with N varying.

So in this game, you run trials until you have 5 successes, then you quit.
And you would like to know with 95% probability how many trials it will take???

0

IssacJonesAuthor Commented:

p = 0.3 is the success (do a google on Bernoulli trials for more information) but it would be any probability.

The terms of bet or nature aren't important. This is merely a mathematical query.

In the calculator method you are looking at you are considering a completely different problem.

Look at it this way, if I were to take N=16 there is roughly a 21% chance of getting 5 occurrences. So, we can agree, that if we got 5 occurrences, it is fairly likely that the N we started off with was N=16. Similarly, N=17 would be a reasonable answer.

However, the probability of getting 5 successes in N=1000000000 is incredibly small.

As such, there must be a range of values for N which we could be almost certain (well, 95% certain) that these were the number of trials that gave us 5 successes.

Sorry if I haven't explained myself clearly enough.

From the calculator above: If N=7 and p=0.3 you will get exactly 5 successes 2.5% of the time. If N=8 and p=0.3 you will get exactly 5 successes 4.6% of the time. If N=30 and p=0.3 you will get 4 or fewer successes 3.0% of the time.So I think the range of N you need for 95% confidence is 7 to 30.

>> Look at it this way, if I were to take N=16 there is roughly a 21% chance of getting 5 occurrences.
So, we can agree, that if we got 5 occurrences, it is fairly likely that the N we started off with was N=16.

I don't think we can agree to that at all. What do you you mean by fairly likely?

I think we might be able to agree that N is between 7 and 30.

r = your number of successes required
p = probability
alpha = tolerance level, so for 95% success level, alpha = .95

important to note I've done that the other way around

if you add a module to excel, then the code will give you an in built function 'SolveForAlpha'

e.g

+SolveForAlpha(10, .256, .999)

Function SolveForAlpha(r As Integer, p As Double, alpha As Double) As Integer Dim q As Integer 'lowest test n we can have is r q = r Do Until probGE(q, r, p) >= alpha q = q + 1 Loop SolveForAlpha = qEnd FunctionFunction probGE(n As Integer, r As Integer, p As Double) As Double Dim c As Integer For c = r To n probGE = probGE + prob(n, c, p) NextEnd FunctionFunction prob(n As Integer, r As Integer, p As Double) As Double prob = p ^ r * (1 - p) ^ (n - r) * nCr(n, r)End FunctionFunction nCr(n As Integer, r As Integer) As Double Dim c As Integer nCr = fact(n) / fact(r) / fact(n - r)End FunctionFunction fact(ByVal n As Integer) As Double If n <= 0 Then fact = 1 Else fact = fact(n - 1) * n End IfEnd Function

by the way that is '5 or more successes', it has to be that way clearly, otherwise for large values of n, the chance of any particular r can become small.

0

IssacJonesAuthor Commented:

d-glitch:" When you talk about a 95% confidence level on the range, do you want to assign 2.5% to the low end and 2.5% to the high end?" Yes

re: fairly likely. Well, it is more likely than it being from N=10000000000000. Apologies for the wording.

I ran the following simulation in Excel 200 times:

Flip your p=0.3 coin 32 times. Keep track of the trial where the 5th success occurs.
When your done, sort the data and throw away the ten lowest and ten highest numbers.

In one of my cases they were 6 6 6 7 7 7 8 8 8 8 ...... 30 30 30 31 31 31 32 32 32 32