# Statistical probability in JavaScript

#### torpiler

Statistical probability wise is 4/5000 the same as 1/1250?

#### CodeMonkeyJ

Yup, 4/5000 reduces down to 1/1250. No fancy math needed.

#### torpiler

Yup, 4/5000 reduces down to 1/1250. No fancy math needed.
If the chance is a multiple event win would the result remain the same? What of exponential decay in such a case?

#### CodeMonkeyJ

I need more context. Is the "multiple event win" reducing the possibilities, e.g., removing a marble from a bag, or are the odds the same each time, e.g., spinning a slot machine (which would be zero decay)? What result are you looking for? The total odds of winning if it was soun multiple times?

#### torpiler

I need more context. Is the "multiple event win" reducing the possibilities, e.g., removing a marble from a bag, or are the odds the same each time, e.g., spinning a slot machine (which would be zero decay)? What result are you looking for? The total odds of winning if it was soun multiple times?
Total odds i.e 1/5000 spun four times vs, 1/1250

#### CodeMonkeyJ

To combine all four spins into a total probability that at least one win, you use the "at least one rule." First, find the probability that all of them will _fail_. Then, subtract it from one.

Code:
``````P(all) = (1 - 1/5000) * (1 - 1/4000) * (1 - 1/3000) * (1 - 1/2000)
P(at least one) = 1 - P(all)
P(at least one) = 1 - (0.9998 * 0.99975 * 0.999666 * 0.9995)
P(at least one) = 1 - 0.998717 = 0.00128 = 0.128%``````

For four spins of 1/1250, it's the same process, but a little more simplified.

Code:
``````P(fail) = 1 - 1/1250 = 1 - 0.0008 = 0.9992
P(at least one) = 1 - 0.9992^4 = 1 - 0.9976 = 0.0024 = 0.24%``````

• torpiler

#### torpiler

To combine all four spins into a total probability that at least one win, you use the "at least one rule." First, find the probability that all of them will _fail_. Then, subtract it from one.

Code:
``````P(all) = (1 - 1/5000) * (1 - 1/4000) * (1 - 1/3000) * (1 - 1/2000)
P(at least one) = 1 - P(all)
P(at least one) = 1 - (0.9998 * 0.99975 * 0.999666 * 0.9995)
P(at least one) = 1 - 0.998717 = 0.00128 = 0.128%``````

For four spins of 1/1250, it's the same process, but a little more simplified.

Code:
``````P(fail) = 1 - 1/1250 = 1 - 0.0008 = 0.9992
P(at least one) = 1 - 0.9992^4 = 1 - 0.9976 = 0.0024 = 0.24%``````
Thanks so much for the explanation!