Pipeline Pilot does not have a built-in cumulative distribution function but I found the below procedure to calculate it on Wikipedia (https://en.wikipedia.org/wiki/Normal_distribution#Cumulative_distribution):
The Pascal code is easily translated into Pilotscript but how many iterations are needed? I tried a few numbers in the script below
cdf_input := 1.0;
iterations := '10,100,1000,10000,100000';
expand(',', iterations);
resize(results, 0);
resize(digit, 0);
for #i in 1 .. numvalues(iterations) loop
// calculate CDF function for cdf_input
#value := cdf_input;
#sum := cdf_input;
#counter := 1;
while #counter <= iterations[#i] loop
#value := ((#value * cdf_input * cdf_input) /((2*#counter) + 1));
#sum := #sum + #value;
#counter++;
end loop;
#CDF := 0.5 + (#sum/sqrt(2.0*pi()))*exp(-(cdf_input*cdf_input)/2);
append(results, format('%.50f', #CDF));
append(digit, floor(-log10(#value)));
end loop;
with the following results, i.e. anything more than ~100 iterations won't change the value.
| iterations | results | digit | |
| 10 100 1000 10000 100000 | 0.84134489022862358000000000000000000000000000000000 0.84134489022942061000000000000000000000000000000000 0.84134489022942061000000000000000000000000000000000 0.84134489022942061000000000000000000000000000000000 0.84134489022942061000000000000000000000000000000000 | 10 189 Infinity Infinity Infinity |
0.84134475
The pilotscript calculated value starts to diverge after the 6th digit. In the application I have in mind the value of the 7th digit is irrelevant but still this is strange. I am not losing sleep but if anyone can tell me what went wrong that would be appreciated.
A native PP CDF/erf function would equally be appreciated.
Willem van Hoorn
