import std.math: feqrel; // TODO: Use verified test points. // The values below are from Excel 2003. assert(fabs(normalInvCDF(0.001) - (-3.09023230616779))< 0.00000000000005); assert(fabs(normalInvCDF(1e-50) - (-14.9333375347885))< 0.00000000000005); assert(feqrel(normalInvCDF(0.999L), -normalInvCDF(0.001L)) > real.mant_dig-6); // Excel 2003 gets all the following values wrong! assert(normalInvCDF(0.0) == -real.infinity); assert(normalInvCDF(1.0) == real.infinity); assert(normalInvCDF(0.5) == 0); // (Excel 2003 returns norminv(p) = -30 for all p < 1e-200). // The value tested here is the one the function returned in Jan 2006. real unknown1 = normalInvCDF(1e-250L); assert( fabs(unknown1 -(-33.79958617269L) ) < 0.00000005);