The following code in cfscript attempts to calculate probability of certain thing, please take a look at comment out original code as well.

```
<cfscript>
// function AttackerSuccessProbability(double q, int z) {
function AttackerSuccessProbability(q, z) {
// double p = 1.0 - q;
p = 1.0 - q;
// double lambda = z * (q / p);
lambda = z * (q / p);
// double sum = 1.0;
sum = 1.0;
// int i, k;
for (k = 0; k <= z; k++) {
// double poisson = exp(-lambda);
poisson = exp(-lambda);
for (i = 1; i <= k; i++)
poisson *= lambda / i;
// sum -= poisson * (1 - pow(q / p, z - k));
sum -= poisson * (1 - (q / p)^(z - k));
}
// return sum;
writeOutput(sum); writeOutput("<br>");
}
AttackerSuccessProbability(0.01,0);
AttackerSuccessProbability(0.01,1);
AttackerSuccessProbability(0.01,2);
AttackerSuccessProbability(0.01,3);
AttackerSuccessProbability(0.01,4);
AttackerSuccessProbability(0.01,5);
writeOutput("<br>");
AttackerSuccessProbability(0.03,0);
AttackerSuccessProbability(0.03,5);
AttackerSuccessProbability(0.03,10);
AttackerSuccessProbability(0.03,15);
AttackerSuccessProbability(0.03,20);
AttackerSuccessProbability(0.03,25);
</cfscript>
```

The above generates the following respective results:

1

0.020049659504

0.000501302822

0.000013032317

0.000000344131

0.0000000091611

0.000002232864

0.000000000008

0

0

0

Expected respective results:

q=0.1 z=0 P=1.0000000

z=1 P=0.2045873

z=2 P=0.0509779

z=3 P=0.0131722

z=4 P=0.0034552

z=5 P=0.0009137q=0.3 z=0

P=1.0000000

z=5

P=0.1773523

z=10

P=0.0416605

z=15

P=0.0101008

z=20

P=0.0024804

z=25 P=0.0006132

Question, is there a way to substitute the â€śdoubleâ€ť type or another technique to achieve more accurate results with cf or lucee?

Thanks.