How to calculate probability of the same events happening 3 times in a row, from binomial distribution given n trials?

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.
Laszlo BenedekAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

ozoCommented:
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";
}

Open in new window

ozoCommented:
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";
}

Open in new window

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Laszlo BenedekAuthor 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.
Rowby Goren Makes an Impact on Screen and Online

Learn about longtime user Rowby Goren and his great contributions to the site. We explore his method for posing questions that are likely to yield a solution, and take a look at how his career transformed from a Hollywood writer to a website entrepreneur.

ozoCommented:
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
Laszlo BenedekAuthor 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
Laszlo BenedekAuthor Commented:
I could have given a smaller example than 100 for "small" n, but I think the formula would be the same.
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Math / Science

From novice to tech pro — start learning today.