# Thread: Help with probability and averages

1. ## Help with probability and averages

I have four scenarios with five rounds each where an event x, y, or z will be chosen.

In the first scenario, each round has a equal chance of triggering event x and will continue triggering event y each round until event x is triggered. Example1: if event x is triggered on r1, y=0. Example2: if event x is triggered on r3, y=2. Example3: if event x is triggered on r5, y=4.

In the second scenario, each round has a 20% chance of triggering event x and will continue triggering event y each round until event x is triggered. Example: event x is triggered on r1, y=0. Example2: event x is triggered on r4, y=3. Example3: event x is never triggered, y=5.

In the third scenario, each round has a 75% chance of triggering event x and if it is not triggered that round it will trigger event y. Example1: event x is triggered every round, y=0. Example2: event x is triggered on rounds 1,2,and 5, y=2. Example3: event x is triggered on rounds 3 and 4, y=3.

In the fourth scenario, rounds 1 through 4 each have a equal chance of triggering event x. Each round x has not been triggered, there is a 50% chance that event y will trigger else event z will trigger. Once x has been triggered, event y will not trigger. Example1: event x triggers on round 1, y=0. Example2: event x triggers on round 4, y triggers on round 1 and 3, y=2.

I am trying to learn how to calculate the average on the amount of times event y will trigger in each scenario based on the probabilities given in each scenario. I took calculus in high school so I am a little rusty on my math, but if someone explained it I would understand.

Here are my attempts:

Scenario #1
If each round has an equal chance of triggering event x, and there are five rounds, that would mean that each has a 20% chance to trigger. So I would think the formula would be:
((.2*0)+(.2*1)+(.2*2)+(.2*3)+(.2*4))/5 = 40% chance to trigger y each round

Scenario #2
I am not sure how to do this one as it should be different from scenario 1, and I think I messed up on scenario 1.

2. ## Re: Help with probability and averages

Your a little ambiguous about what your looking for and what exactly what happens if X triggers. I will go over each and what I think you mean:

Scenario 1: Each Round chance of Event X = P(x). If not Y triggers and thus P(y)=1-P(x). If X triggers it sets P(y) = 0.
For the average number of Ys (which your formula seemed to be going after):
$0.2*0+.8*.2*1+0.8^2*0.2*2+0.8^3*0.2*0.8^4*4+0.8^5* 5$
The reasoning for the above is each round there is an 80% chance of the last round not rolling an X, and a 20% chance we do roll an X, thus setting Y to a fixed number. So on round 3 we have 80%(no round 1)*80% chance(no round2)*20%(we got an x this round)*2 (the number of previous Ys so far). With the final one just being the odds of no X ever being rolled*5. This generalizes into:
$\sum_{i=0}^{n-1}\displaystyle{[}P(x)*P(y)^i*i\displaystyle{]}$+ $P(y)^n*n$

$n=number\ of\ rounds$
$P(x)=1/n$
$P(y)=1-P(x)$

To find out the chance that y would trigger at all, or to put it another way. The chance that Y >=1 is simply 1 - chance that Y never trigers or:
$1-P(x)^n$

Scenario 2: This is just scenario 1 with $N=5$

Scenario 3: This is the opposite of Scenario 1. Each round X triggering is P(x) and Y triggering is 1-P(x), but each round is independant of the previous. Thus we need to count all the combinations of ways to get Ys. For example we must count XXYYX as well as YXYXX when counting up y=2. The binomial probability theorem hands this quite well. Here is the link:

Binomial probability - Wikipedia, the free encyclopedia

Assume that binomial probablity theorem is:
$P(k,n) = k\ success\ in\ N\ Trials$

Then the average number of Ys is:
$\sum_{i=0}^{n}P(i,n)*i$

and the odds of Getting at least 1 Y are:
$1-P(0,n)$

Scenario 4: This is just a modified case of Scenario 1 above. We just need to add one more variable, chanceZ. So the new formula for average looks almost the same, except note that P(y) is different:

$\sum_{i=0}^{n-1}\displaystyle{[}P(x)*P(y)^i*i\displaystyle{]}$+ $P(y)^n*n$

$n=number\ of\ rounds$
$P(x)=1/n$
$P(y)=(1-P(x))*(1-chanceZ)$
$P(z)=(1-P(x))*chanceZ$

You can determine the average number of Z's by substituting P(z) for P(y) in the above formula. Note for chanceZ =.50 (your case) Average Y == Average Z.

The chance of at y triggering (Y>=1) changes a little as well. Its still 1 - Chance that Y doesn't trigger. But each round Y not triggering is found by:
$P(x)+P(z)$ and thus:

$1-(P(x)+P(z))^n$ is the chance of at least 1 Y.

Just for clarity your sample case above for Scenario 4 is specifically
$n=4$
$chanceZ=.50$
and those are the only 2 variable needing to be specified to solve any case

Tony Chamberlain

3. ## Re: Help with probability and averages

I am sorry if I was ambigious. And I will try to clarify. The only thing that I am trying to calculate is the chance that y will happen. x is just used to figure out when y would occur (and z is needed because I don't want x to occur yet). Thanks for the help because it helped me see things easier.

I was unclear on what scenario 1 was. It is hard for me to explain better so I will try with another example. First you ask for a random number between one and five. Depending on what number it hits, means which round x will trigger. If the round is before x is triggered, y will occur each round. If the round is equal to or after x is trigger, y will not occur each round. So x has to trigger on one of the rounds, and each round has a equal chance (with each other) of triggering x.

I think you got scenario 2 spot on with the formula for scenario 1. So this is what I am getting:
Percent chance of getting y if x is triggered on round 1: .2*0=0%
if triggered on round 2: .8*.2*1=16%
if triggered on round 3: .8*.8*.2*2=25.6%
if triggered on round 4: .8*.8*.8*.2*3=30.72%
if triggered on round 5: .8*.8*.8*.8*.2*4=32.768%
if never triggered at all: .8*.8*.8*.8*.8*5=163.84% (or would this be just 100%?)
So that means to get the average chance of y occuring in a round for scenario 2, you would add all the percentages up and divide by the total possibilities?
Which would mean: (0+.16+.256+.3072+.32768+1.6384)/6 = 44.82% chance of y occuring in a given round for scenario 2. The only thing that is bothering me is that one of them is greater than 100%, but if it makes sense to you, I am all for it!

I was probably being unclear on scenario 3 as well, but the link you gave me about the binomial probability I think fixed the problem I was having. Just to make sure I am doing it right, I will put out my work on what I think the probability is.
The probability of getting n number y's in any round:
p(n)
p(0)=((5!)/(0!*5!))*(.25)^0*(.75)^5
p(0)=23.73%
p(1)=((5!)/(1!*4!))*(.25)^1*(.75)^4
p(1)=39.55%
p(2)=((5!)/(2!*3!))*(.25)^2*(.75)^3
p(2)=26.37%
p(3)=((5!)/(3!*2!))*(.25)^3*(.75)^2
p(3)=8.79%
p(4)=((5!)/(4!*1!))*(.25)^4*(.75)^1
P(4)=1.46%
p(5)=((5!)/(5!*0!))*(.25)^5*(.75)^0
p(5)=0.10%
Which means to calculate the average probability of getting a y in a round during scenario 3, you add up the percentages multiplied by n and divide by the total possibilities:
(.2373*0+.3955*1+.2637*2+.0879*3+.0146*4+.0010*5)/6 = 20.83%
Which means that if I am doing it right, it strangely has half the chance as the second scenario.

Since I was unclear on scenario 1 and scenario 4 is similar (albeit more complex), I am not sure if the formula will work. I will try to give a better explanation. First you get a random number between 1 and 4. That random number will determine on which turn x is triggered. On each turn before x is triggered, you get a random number that is either 1 or 2. If it is one, y is triggered. If it is two, z is triggered. On the turn x is triggered and on each turn after, y cannot be triggered (so assume x or z is triggered, it doesn't matter, as all we care about is y). That means round 4 and round 5 cannot trigger y under any circumstances, as x must be triggered by round 4.

I hope this is clearer. If someone can still help me with scenario 1 and 4 and check to make sure I am doing it right on scenarios 2 and 3, I would be grateful. If it is still unclear, just say so and I will try to clear it up. Thanks for the help!

4. ## Re: Help with probability and averages

Ok I think I got what your trying to find now. Originally it seemed 1,2,4 are all cases of the same generalized idea. While 3 is diffrerent and I believe fully covered. I would like to cover one more formula and a mistake you made on my original understanding of your problem first.

I was under the impression that each round X has a P(x) chance to occur with the possibility that it might NEVER occur. IMPORTANT: All the formula above are under the assumption that we roll a chance for P(x) EVERY round and there is a chance it NEVER occurs. If that is the case the above formulae are exactly correct, though I didn't give a specific formula for ther probability of X occurring at exactly round A. The formulas I gave were for the AVERAGE number of Y's of an infinite runs of the game, and the probability of getting at least 1 Y.

Here is the probability of X happening at Round A :
$(1-P(x))^{a-1}*P(x)$
That is each round we multiply the chance X didn't happen then finally the chance it did. So if X happens on round 3. A=3. Then its (1-P(x) )^2*P(x) or 0.8^2*0.2.

Note the formula you were solving where you ended up with a 163.84% was not intended to give percentages. That was intended to give average number of Ys. So it was actually .16 Ys + .256 Ys + .3072 Ys + .3276 Ys + 1.63Ys = 2.6 Ys.
If you played that game over and over.. You'd find the averge number of round that had a Y was 2.6. Not a chance of Y happening at any specific time (which I just gave above).

Again Note Formulas for Scenario 2,4 (as well as my mistaken understaning of 1) are all just variations of each other and are fundamentally the same. Scenario 2 is just Scenario 4 where chanceZ = 0.0.

Ok now thats cleared up, I realized what your asking for in Scenario 1 is fundamentally different than 2 or 4. In that case P(x) is evenly distributed across the 5 round, and $\sum_{i=1}^{n}P(x) = 1$. That is X is guaranteed to happen.
So for this case P(x) and P(y) are still:
$P(x)=1/n$
$P(y)=1-P(x)$

But we handle them a little different. We aren't rolling the percentage each round to get a running total of chances. We are making only ONE roll, and setting that number to be the round. This is actually a much simpler formula. It is effectively asking what is the chance of rolling a number on a N sided dice.
The Chance of Y=A is simply
$P(x)$
where $0\leq\ A \leq n-1$

The Average number of Ys in N rounds is
$\sum_{i=1}^{n}P(x)*(n-1)$
THIS ISN'T A PERCENTAGE but an actual number of expected number of Y's you would get at the end of a game.

Does that clear up the last of the questions?

5. ## Re: Help with probability and averages

I am beyond lost right now. I think I am explaining things way wrong.

Scenario 1 and part of scenario 4 should be the ones that are similar. In both, event x will eventually happen once. In scenario 1 it will happen in round 1 to 5 (so you ask a random number generator for a percentage one time, if the percentage is between 01-20, you get round 1, if the percentage is between 21-40, you get round 2, etc) and in scenario 4 it will happen in round 1 to 4 (similar except 01-25). Scenario 2 should be the different one since each round only has a 20% chance of letting event x happen, so it is possible that it could never happen (you ask a random number generator for a percentage each round, and it hits the 21-100 in all five rounds).

Scenario 3 and the second part of scenario 4 are also similar in that x (or z) does not stop y from occuring in subsequent rounds.

Scenario 4 is supposed to be the most complicated as it is kind of a mix between scenario 1 and 3 (so I think you end up having to use both formulas?)

To be clear what I am trying to find out is that if I was to play a scenario an infinite amount of times, what is the average amount of y's I would get in each scenario and how to calculate it (so I can play around with the percentages).

Ok I get now that the formulas are not supposed to give percentages. They give the average number of y's in a given round. What I still don't understand though is how round 5 of scenario 2, you get an average of more than 1 y when it is impossible to get more than one y in a given round.

Ok now thats cleared up, I realized what your asking for in Scenario 1 is
fundamentally different than 2 or 4. In that case P(x) is evenly distributed
across the 5 round, and

$\sum_{i=1}^{n}P(x) = 1$. That is X is
guaranteed to happen.
So for this case P(x) and P(y) are still:

$P(x)=1/n$

$P(y)=1-P(x)$

But we handle them a little different. We aren't rolling the percentage
each round to get a running total of chances. We are making only ONE roll, and
setting that number to be the round. This is actually a much simpler formula.
It is effectively asking what is the chance of rolling a number on a N sided
dice.
The Chance of Y=A is simply

$P(x)$

where

$0\leq\ A \leq n-1$
Ok I read that about ten times and it is still going over my head. But I am just going to plug in stuff into the formula and see if it looks right for scenario 1.

if x is triggered in round 1: .20*0=0
round 2: .20*1=.20
round 3: .20*2=.40
round 4: .20*3=.60
round 5: .20*4=.80

then sum it all up:
0+.2+.4+.6+.8=2.00
So if I ran scenario 1 an infinite amount of times, I would get an average of 2 y per scenario. (LOLed when I realized that my original formula for scenario 1 was almost right)

Scenario 2 I am confused because I don't understand how a given round can given an average of more than 1 y when it is only possible to get 1 y per round. But you are saying that if you run scenario 2 an infinite number of times, on average you will get 2.69 y per scenario. This does seem right.

In scenario 3, I should correct what I did before by just adding up without dividing?
.2373*0+.3955*1+.2637*2+.0879*3+.0146*4+.0010*5=1. 25
Which means that if you run scenario 3 an infinite number of times, on average you will get 1.25 y per scenario. This makes sense because you end up getting y 25% of the time each round and 25% of y is 1.25.

So scenario 4, I should need to combine parts of scenario 1 and scenario 3. So I am going to invent an event w to help me seperate them. So this would be the logic:
First determine what round event x occurs (01-25 means round 1, 26-50 means round 2, 51-75 means round 3, 76-100 means round 4). If event x has not yet occured, event w occurs. When event w occurs, you have a 50% chance of getting event y and else you get z.
So the probability of w occuring would be:

sum(n=1->5) P(x)*(n-1)

So if x is triggered in round 1: .75*0=0
round 2: .25*1=.25
round 3: .25*2=.50
round 4: .25*3=.75

0+.25+.5+.75 = 1.5
So if I ran scenario 4 an infinite number of times, I would get an average of 1.5 w per scenerio.
Now I am stuck I wanted to use the formula in scenario 3, but I got confused on how to use it. But logically, you get a y 50% of the time you start event w right? So if you run scenario 4 an infinite amount of times, you should get an average of .75 y per scenario.

So if I did everything right, the order in which y has the greatest probability of happening is 2,1,3,4.

Thank you for the help. If everything looks right, let me know I i'll mark this as solved!

edit: noticed a math error.

6. ## Re: Help with probability and averages

First off I'd like to apologize. I wasn't understanding you, and instead of clearly stating what I thought you meant and making sure we were on the same page I just barrelled ahead.

To remedy this I will describe 4 scenarios.. and 4 different formula you can generate for each. I suggest forget everything we discussed so far and If i'm 100% on base with my understanding of each scenario let me know, and if you want I can make write out concise formula for each. (Either all 4, or just specific ones you want.) With some examples. After that I wanted to make 2 quick points about mistakes you were making that you should read. But mainly let me know if what I just described would be helpful to do.

I think in the future if you are explaining a problem, try just stating it by describing exactly what you would do physically, and worry about math terms and semantics later. One big problem I was having understanding is there is 2 ways you can have Event X happen. Here is how I would have described them by physical actions and it would have left no ambiguity at all. Hopefully the following is exactly what you meant and if it is, we can go forward from there.

Scenario 1 and 4: I have a scenario with N rounds. I will randomly create a number from 1 to N, call this number A. In rounds 1 to A-1, Event Y will be generated. In rounds A to N. Event X happens. (4 Just add the extra stipulation that Event Y is actually, 50% Y and 50% Z but fundamentally the same.) For exampe: I have 5 rounds. I roll a 3. Round 1-2 Y happens. Round 3-5 X happens.

Scenario 2: In this scenario. There are N rounds. Each round Event X will happen with a probability of P(x). If it doensn't happen Event Y happens. Continue checking P(x) each round until it occurs. When it does occur Event X will happen every round thereafter with 100% probablility. Thus if Event X never occurs, event Y will occur in all N rounds.

Scenario 3: In this scenario there are N rounds. Each round Event X will happen with a probability of P(x). If it doesn't happen Event Y happens. Check Event(x) every round independant of results in previous round. Even if X happens in one round, Event Y can still happen in future rounds.

I hope that is perfectly clear you just roll 1 dice in Scenario 1 and 4, and X will be guaranteed to happen at some round. While in Scenario 2 and 3 Event X might never happen. I often find physically describing what you would do without any abstractions is helpful in clarity.

I think you've mostly got it. I think you are confusing some basic ideas about whats happening in each.

There are 4 totally different but related things you can calculate in each case. Also I"m not sure what you meant by:
"I am trying to learn how to calculate the average on the amount of times event y will trigger in each scenario based on the probabilities given in each scenario." I assume its either 1 or 2, or both. Though 3 and 4 might be useful to know as well.

Formula 1: The chance that Y will occur at all. I don't care when Y occurs, or how many rounds Y occurs in. I just want the chance it will happen at all. This IS a percentage. It will only be ONE percentage.

Formula 2: The chance that Y will occur in any specific round. This IS a percentage. It will be N different percentages.. One for each round.

Formula 3: The percentage that a paticularly number of Y will be generated after N rounds. For example what the odds that only 1 Y is generated, or 3 Ys are generated. This will be a percentage. There will be MAXY number of them. MAXY changes from scenario to scenario, but in each $0 \leq Y \leq MAXY$

Formula 4: After running all N rounds, what should the average number of times Event Y happens. This is just a number. It is related very closely to 3 above. For every different number of Y, you just mulitply that percentage * the number of Ys and add them all up. So percentage of 0 Y*0 + Percentage of 1 Y*1 + Percentage of 2 Y *2 ... so on.

While they are related, you can't plug numbers into one equation and try to get answer for another. For example your still doing that with Scenario 3 numbers.

For example you said:
In scenario 3, I should correct what I did before by just adding up without dividing?
.2373*0+.3955*1+.2637*2+.0879*3+.0146*4+.0010*5=1. 25
To start with those are percentage chance of getting 0Y, 1 Y, 2Y.... 5Y. Also they add up to 1.0 not 1.25. (You did a slight adding error ) Which makes sense, since the total percentages covering all possible value of Y should always equal 1. That sequence will not generate the average number of Y.

Another point ,and its an easy trap to fall into.. you can't compare 2 values like average number of Ys and make assumptions the other equations. You said:
So if I did everything right, the order in which y has the greatest probability of happening is 2,1,3,4
I believe you got this ordering from the average number of Ys. If all you meant was the average number of Ys was greater for 2 than 4 thats fine. But if you meant Y is more likely to occur in 2 than 4.. that is totally unprovable and may not even be TRUE!!

Here is an example.
99% of the time I will generate 1Y. 1% of the time I wll generate 0 Y.
Average number of Ys == .99
Chance of Y happening 99%

1% of the time i generate 1000 Ys. 99% of the time I generate 0Y
Average number of Ys = 10
Chance of Y happening = 1%.

Clearly we can make no assertions about chance of Y happening based on the average number of Ys, or vice versa

Please let me know if you want me to do do the formulation I described above.

7. ## Re: Help with probability and averages

First off, thank you for taking the time to explain this for me.

You are almost exactly right for what I want in describing the formulas (and as I compare your version to my original, I don't wonder why anyone would get confused). It may not matter but your version of scenario 4 would only have 4 rounds. I need to be able to compare each scenario (so I think its important that each scenario has equal rounds). Thats why I was trying to describe your version plus an extra round that in terms of y is useless. So scenario 4 has a "handicap" because it is running for one round less than the others. If I can compare scenarios with different number of rounds, great. Otherwise you understand my scenarios.

As for my goal, I am actually looking for formula 4. I am looking to compare the average number of times event y will happen in each scenario. I will also like to learn how to calculate it so I can make more scenarios based on these four structures (by playing with the percentages or amount of rounds).

Also I am still getting 1.25 when I add up the numbers:

(.2373*0)+(.3955*1)+(.2637*2)+(.0879*3)+(.0146*4)+ (.0010*5)=
(0)+(.3955)+(.5274)+(.2637)+(.0584)+(.005)=1.25

I did it both on the calculator and by hand just in case the calculator was messing with me.

So since I want formula 4, can I say:
scenario1=2.00
scenario2=2.69
scenario3=1.25
scenario4=0.75
So from greatest to lowest: 2,1,3,4?
Or do I need another formula?
Thanks again for the help!

8. ## Re: Help with probability and averages

Oh yes your exactly right I didn't see you multiply by round number. So yes that is exactly right. I'm not sure why you say my scenario only goes 4 rounds. that might have just been a specific example. Every formula I gave was for N rounds.. You could have any number of rounds you want and it would work. I will give the Average Ys for each and the specific example of 5 rounds.

Scenario 1 and 4: Its the same forumla. P(z) = 0 for Scenario 1.

Average Number of Y:
$\sum_{k=2}^{n}P(x) P(y) (k-1)$
$n=Number\ of \ rounds$
$P(x)=1/n$
$P(y)=(1- P(z))$
$P(z)=User\ Defined$

Note: P(y) is not the actual chance of Y occuring, but a term used to break down whether Y or Z occurs if X didn't.

Scenario 2:
$\sum_{k=2}^{n}P(Y)^{i-1}P(x)(k-1)$ + $P(Y)^n\cdot n$
$n=Number\ of \ rounds$
$P(x)=1/n$
$P(y)=(1-P(x))$

Note: The last term is not part of the summation, but an extra addened to account for the case when X doesn't not occur at all.

Note: We only go from 2 to N because if X triggers in round 1, here will be 0 Ys generated (n-1). So for k=1, the whole equation is multiplied by 0 and not relevant. This doesn't mean we ignore the first round X Chance. Its represented by the fact that the chances of Round2 through RoundN sum to less than 100%. Round 1's percentage is that lack.

Scenario 3:
$\sum_{k=1}^{n}\binom{n}{k}p^k q^{n-k}\cdot k$
$n=Number\ of \ rounds$
$P(x)=q=1/n$
$P(y)=p=(1-P(x))$
$k=number\ of\ times\ Y\ happened$

EXAMPLES: N=5 for all scenario. See if you get the same answers as me. If you don't understand why a formula works, let me know. I won't fully explain them all because that could get lengthy and you might already understand it all.

SCEN 1: P(z)=0. P(x) = .20 P(y)=1.0 (If X fails Y will always happen).
.2*1.0*1+ .2*1.0*2+.2*1.0*3+.2*1.0*4 = 2

SCEN 4: P(z)=.5 P(x) = .20 P(y)=.5
.2*0.5*1+ .2*0.5*2+.2*0.5*3+.2*0.5*4 = 1

(This makes sense. Scenario 1 and 4 are exactly the same except for P(z) chance of happening. If P(z) = 50% we should get exactly half as many Ys.)

SCEN 2: P(x) = .20 P(y) = .80
.80*.2*1 + .80^2*.2*2+ .80^3*.2*3+ .80^4*.2*4 + .80^5*5=2.69

SCEN 3: P(x)=q=.2 P(y)=p=.8
5*.8*.2^4*1+ 10*.8^2*.2^3*2+ 10*.8^3*.2^2*3+5*.8^4*.2*4+1*.8^5*5=4

So I get 3 2 1 4 for the order from greatest to smallest.

Let me know if you don't come up with the same answers and/or if you don't understand why a particular formula looks the way it does.

9. ## Re: Help with probability and averages

Thank you! This these formulas worked for me.