How to calculate probability of the same events happening 3 times in a row, from binomial distribution given n trials? Laszlo Benedek used Ask the Experts™
on
In a game (XCOM) you have a stated chance of hitting the target. You either hit or miss. Let's say your chance of hitting is 90% every time.

I want to know the chance of 3 misses (10% each) happening 3 times in a row anywhere given n trials (let's say 50, 100, 200 etc)

Ideally I'm looking for a simple solution, and it can be an approximation.

The only way I can think is working out permutations for each possible number of misses (probability of x number of misses calculated from binomial formula) but that would take quite a long time. I'm wondering if there's a more elegant way.

Optional
It would be also nice to know the probability of at least 1 such streak, at least 2 etc.
Comment
Watch Question

Do more with EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
Most Valuable Expert 2014
Top Expert 2015

Commented:
Here's a program to generate those probabilities:
#!/bin/perl
@p=(0,0,0,.001,.0019,.00280,.003700);
for \$n (3..6){
print "\$n \$p[\$n]\n";
}
for \$n (7..200){
print \$n," ",\$p[\$n]=1.9*\$p[\$n-1]-.81*\$p[\$n-2]-.081*\$p[\$n-3]-.0090*\$p[\$n-4],"\n";
}
Most Valuable Expert 2014
Top Expert 2015
Commented:
This version should reduce the accumulation of floating point rounding errors
#!/bin/perl
@P=(0,0,0,10000000000000,19000000000000,28000000000000,37000000000000);
for \$n (3..6){
print "\$n ",\$P[\$n]/10000000000000000,"\n";
}
for \$n (7..200){
print \$n," ",(\$P[\$n]=(1900*\$P[\$n-1]-810*\$P[\$n-2]-81*\$P[\$n-3]-9*\$P[\$n-4])/1000)/10000000000000000,"\n";
}

Commented:
Thanks. Is there a site where they explain the math behind it, so that I can understand better how this is calculated. When I tried to make my similar software I found out that I don't know how calculate permutations with 3 next to each other given x number of misses.
Most Valuable Expert 2014
Top Expert 2015

Commented:
I actually cheated a little by counting the number of permutations for small n, then using oeis.org to derive a recurrence formula.  In principle you could also derive the recurrence by thinking carefully about how to extend known solutions when you add more trials.  Or by solving a set of simultaneous linear equations relating the values for n...n+4

Commented:
I have smaller problems than that. I couldn't even correctly derive the formula for small n.

I could not work out how to solve for the permutation: eg from 100 trials 6 missed, what's the chance 3 of those 6 misses are next to each other?

Optional further explanation.

I have an excel sheet of what I wanted to do. Let's say I have 100 trials.
The first column is the number of misses (everything from 0-100, as you could have no miss, 1 miss ... etc or all 100 misses). The next column is is the chance of that combination: eg the chance of having 6 misses in any order out of 100. (I'm pretty sure this is correct so far)

Next I wanted to calculate the chance that I get a correct permutation (with 3 consecutive misses) given that I already know the number of misses in total for that row, so the total chance would be the multiple of the 2 chances for the row and adding all those up is the final total.
Probability.xlsx

Commented:
I could have given a smaller example than 100 for "small" n, but I think the formula would be the same.

Do more with Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.