Learn the fundamentals of the popular programming language JavaScript so that you can explore the realm of web development.

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.

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.

Do more with

EXPERT OFFICE^{®} is a registered trademark of EXPERTS EXCHANGE^{®}

```
#!/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";
}
```

```
#!/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";
}
```

## Premium Content

You need an Expert Office subscription to comment.Start Free Trial