PDA

View Full Version : Probability help.



LeonCross
2015-03-31, 12:03 PM
Slightly off topic, but I'm doing a play by post game and it involves distibuting forces with varying degrees of % chance of success based on distribution. I'm attempting to maximize the the average chance of the least amount of injuries. The problem is, I don't know how to do the math short form.

No injuries is easy, multiply all the odds of success against each other.
All injuries is easy. Multiply all the odds of failure against each other.

It's finding the middle numbers that is vexing me.

I figured there's probably a ton of people here that know how to do this because lulz dice.

The long form isn't bad, like .75 and .6 would be

.75 / .25
.45 / .3 / .15 / .1

So a 45% chance of no failure, 45% chance of one failure, and a 10% chance of two failures.

The problem is I'm looking at around 50+ rolls around, so doing it long form would be impractical.

What's the practical method for doing this sort of thing?

JeenLeen
2015-03-31, 12:20 PM
I'm not quite following what you are going for -- I might just be a little fuzzy in the head today -- but if the issue is having to do something too many times, running a simulation in Excel (or another program, if you know a programming language) could work.

If you put this code into a cell in Excel, it will generate a random d20 result. (Just change 20 to whatever you want for different dice.)


=RANDBETWEEN(1,20)

I think there might be a slightly better method, using just RAND and multiplying it by something to get a whole number, but I can't find where I've done that in the past. (Or maybe this is a better method than what I've use din the past.)

If you put that in a cell, anytime you change something in the worksheet, it regenerates a new random number between 1 and 20. If you put it in A1-A50, that would give you 50 rolls.

LeonCross
2015-03-31, 12:59 PM
Hm. Not sure that would help.

Let's say I have 5 rolls to do, with the % being the odds of success.

50%
60%
30%
90%
15%

I'm trying to find the distribution of odds of:

0 successes
1 success
2 successes
3 successes
4 successes
5 successes

Multiplying all success and failure odds gets me the two far ends of the spectrum easily.

0 successes - 1.19%
1 success - ?
2 successes - ?
3 successes - ?
4 successes - ?
5 successes - 1.215%

I'm just not familiar with the method to easily get the other values.

Galen
2015-03-31, 01:09 PM
First, let's define some terms:

Propability of success: P
Probability of failure: P' (equal to 1-P)
Number of attempts: N
Number of successes: S
Number of failures: F (equal to N-S)


Probability of exactly S successes in N tries is: P^S * P'^F * N!/(S! * F!)

Example:

Probability of success: 70% = 0.7
Probability of failure is therefore: 30% = 0.3
Number of attempts: 6
Number of successes desired: 5
Number of failures is therefore: 1

Probability of exactly 5 successes: 0.7^5 * 0.3^1 * 6!/(5!*1!) = 0.168 * 0.3 * 720 / (120*1) = 30.2%

Also, we calculate:
Probability of exactly 4 successes: 0.7^4 * 0.3^2 * 6!/(4!*2!) = 0.2401 * 0.09 * 720 / (24*2) = 32.4%
Probability of exactly 3 successes: 0.7^3 * 0.3^3 * 6!/(3!*3!) = 0.343 * 0.027 * 720 / (6*6) = 18.5%

And so on.

LeonCross
2015-03-31, 01:14 PM
Thanks! That should help.

How do I translate that to having a series of rolls at different odds, though?

It's not as easy as just finding the average odds (Like, .5 and .9 success would be a 70% success / 30% failure for the equation) is it?

Galen
2015-03-31, 01:23 PM
Taking the average in this case is not precise, but for practical purposes, it might be close enough. Depends on what level of accuracy you're going for. For example:

90% & 50%
odds of two successes: 45%
odds of one success: 50%
odds of two failures: 5%

Now, let's simplify this to 70% & 70%
odds of two successes: 49%
odds of one success: 42%
odds of two failures: 9%

As you can see, it's a bit different.

LeonCross
2015-03-31, 01:30 PM
Is there a way to be more exact, or is that kind of margin for error the best I'm going to get with a simple equation?

Thanks for all the help!

Galen
2015-03-31, 01:36 PM
That's the best accuracy you can get with human calculating abilities. If you want better, follow JeenLeen's cue and do something with excel or write a small program.

LeonCross
2015-03-31, 01:40 PM
Thanks!

The margin for error is certainly a better option than hand writting 2^x multiplications.

^-^

JeenLeen
2015-03-31, 01:46 PM
To do a program for


Let's say I have 5 rolls to do, with the % being the odds of success.

50%
60%
30%
90%
15%

I'm trying to find the distribution of odds of:

0 successes
1 success
2 successes
3 successes
4 successes
5 successes


I would use something like (in Excel):

Have column A be populated with randomly generated d100 rolls.
A1 = RANDBETWEEN(1, 100)
A2 = RANDBETWEEN(1, 100)
A3 = RANDBETWEEN(1, 100)
A4 = RANDBETWEEN(1, 100)
A5 = RANDBETWEEN(1, 100)

In column B, look at the result to see if it is a success or not.
B1 = IF(A1>=50, 1, 0)
B2 = IF(A2>=60, 1, 0)
B3 = IF(A3>=30, 1, 0)
B4 = IF(A4>=90, 1, 0)
B5 = IF(A5>=15, 1, 0)

Then, in another cell (say C1), sum up the results of column B.
C1 = SUM(B1:B5)
This should give you the number of successes rolled.

I ran a quick test, and it looks like this works in Excel.
EDIT: I realize it gives you # of successes, not likelihood of each success, but maybe that's a starter point for you.

LeonCross
2015-03-31, 01:50 PM
Thanks! I'll take a swing at that!

Ts_
2015-03-31, 02:12 PM
Maybe I missed something in the OP, but if you have rolls with success chances 70%, 20%, 45% and 80%, the average number of successes is 0.7 + 0.2 + 0.45 + 0.8. It doesn't get easier than this. :)

Or are you trying to do something more complicated?

Regards
Ts

Radar
2015-03-31, 02:13 PM
(...)
EDIT: I realize it gives you # of successes, not likelihood of each success, but maybe that's a starter point for you.
Which means, you simply need to calculate the same thing many times over and get the distribution of successes from statistics.

veti
2015-03-31, 03:04 PM
Which means, you simply need to calculate the same thing many times over and get the distribution of successes from statistics.

The beauty of Excel is, you can just copy/paste the formulas and perform the same calculation a thousand times on the same sheet, with different random inputs, and sum the results at the bottom. Then regenerate the random numbers a few times, and that'll give you an idea of the likely margin of error.

It's kinda tedious - you could do it a lot better with a programming language - but it's easy.

Radar
2015-03-31, 03:14 PM
The beauty of Excel is, you can just copy/paste the formulas and perform the same calculation a thousand times on the same sheet, with different random inputs, and sum the results at the bottom. Then regenerate the random numbers a few times, and that'll give you an idea of the likely margin of error.

It's kinda tedious - you could do it a lot better with a programming language - but it's easy.
Exactly, but I think I found an even simpler way to solve the problem: there is obviously anydice (http://anydice.com/)!

If you plug in for example this code:

output (1d100 >= 90)+(1d100 >= 50)+(1d100 >= 60)+(1d100 >= 30)+(1d100 >= 15)

you will obtain the relevant statistics for number of successes with singular probabilities easily adjusted separately. This service is a thing of beauty.

LeonCross
2015-03-31, 03:53 PM
*blinks*

Well...that solves that.

Thanks. 0.o