lib/chi-square.js
function calculateNormalZProbability(z) {
    if (z == 0.0) {
        var x = 0.0;
    }
    else {
        var y = 0.5 * Math.abs(z);

        // Here comes the magic.

        if (y >= Z_MAX * 0.5) {
            x = 1.0;
        }
        else if (y < 1.0) {
            var w = y * y;

            x = 0.000124818987 * w -0.001075204047;
            x *= w +0.005198775019;
            x *= w -0.019198292004;
            x *= w +0.059054035642;
            x *= w -0.151968751364;
            x *= w +0.319152932694;
            x *= w -0.531923007300;
            x *= w +0.797884560593;
            x *= y * 2.0;
        }
        else {
            y -= 2.0;

            x = -0.000045255659 * y +0.000152529290;
            x *= y -0.000019538132;
            x *= y -0.000676904986;
            x *= y +0.001390604284;
            x *= y -0.000794620820;
            x *= y -0.002034254874;
            x *= y +0.006549791214;
            x *= y -0.010557625006;
            x *= y -0.010557625006;
            x *= y +0.011630447319;
            x *= y -0.009279453341;
            x *= y +0.005353579108;
            x *= y -0.002141268741;
            x *= y +0.000535310849;
            x *= y +0.999936657524;
        }
    }

    return z > 0.0 ? (x + 1.0) * 0.5 : (1.0 - x) * 0.5;
}
function calculateNormalZProbability(z) {
    if (z == 0.0) {
        var x = 0.0;
    }
    else {
        var y = 0.5 * Math.abs(z);

        // Here comes the magic.

        if (y >= Z_MAX * 0.5) {
            x = 1.0;
        }
        else if (y < 1.0) {
            var w = y * y;

            x = 0.000124818987 * w -0.001075204047;
            x *= w +0.005198775019;
            x *= w -0.019198292004;
            x *= w +0.059054035642;
            x *= w -0.151968751364;
            x *= w +0.319152932694;
            x *= w -0.531923007300;
            x *= w +0.797884560593;
            x *= y * 2.0;
        }
        else {
            y -= 2.0;

            x = -0.000045255659 * y +0.000152529290;
            x *= y -0.000019538132;
            x *= y -0.000676904986;
            x *= y +0.001390604284;
            x *= y -0.000794620820;
            x *= y -0.002034254874;
            x *= y +0.006549791214;
            x *= y -0.010557625006;
            x *= y -0.010557625006;
            x *= y +0.011630447319;
            x *= y -0.009279453341;
            x *= y +0.005353579108;
            x *= y -0.002141268741;
            x *= y +0.000535310849;
            x *= y +0.999936657524;
        }
    }

    return z > 0.0 ? (x + 1.0) * 0.5 : (1.0 - x) * 0.5;
}
function calculateNormalZProbability ( z ) { if ( z == 0.0 ) { var x = 0.0 ; } else { var y = 0.5 * Math . abs ( z ) ; // Here comes the magic.
 if ( y >= Z_MAX * 0.5 ) { x = 1.0 ; } else if ( y < 1.0 ) { var w = y * y ; x = 0.000124818987 * w - 0.001075204047 ; x *= w + 0.005198775019 ; x *= w - 0.019198292004 ; x *= w + 0.059054035642 ; x *= w - 0.151968751364 ; x *= w + 0.319152932694 ; x *= w - 0.531923007300 ; x *= w + 0.797884560593 ; x *= y * 2.0 ; } else { y -= 2.0 ; x = - 0.000045255659 * y + 0.000152529290 ; x *= y - 0.000019538132 ; x *= y - 0.000676904986 ; x *= y + 0.001390604284 ; x *= y - 0.000794620820 ; x *= y - 0.002034254874 ; x *= y + 0.006549791214 ; x *= y - 0.010557625006 ; x *= y - 0.010557625006 ; x *= y + 0.011630447319 ; x *= y - 0.009279453341 ; x *= y + 0.005353579108 ; x *= y - 0.002141268741 ; x *= y + 0.000535310849 ; x *= y + 0.999936657524 ; } } return z > 0.0 ? ( x + 1.0 ) * 0.5 : ( 1.0 - x ) * 0.5 ; }
Calculates the probability for the normal z.

@param {Number} z
@return {Number}
Calculates the probability for the normal z .