cumnormdist()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 18
Code Lines 15

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 2
eloc 15
nc 2
nop 1
dl 0
loc 18
rs 9.7666
c 0
b 0
f 0
1
<?php
2
3
if (!function_exists('cumnormdist')) {
4
    function cumnormdist($x)
5
    {
6
        $b1 =  0.319381530;
7
        $b2 = -0.356563782;
8
        $b3 =  1.781477937;
9
        $b4 = -1.821255978;
10
        $b5 =  1.330274429;
11
        $p  =  0.2316419;
12
        $c  =  0.39894228;
13
14
        if ($x >= 0.0) {
15
            $t = 1.0 / ( 1.0 + $p * $x );
16
            return (1.0 - $c * exp(-$x * $x / 2.0) * $t *
17
                ($t *( $t * ($t * ($t * $b5 + $b4) + $b3) + $b2) + $b1));
18
        } else {
19
            $t = 1.0 / ( 1.0 - $p * $x );
20
            return ($c * exp(-$x * $x / 2.0) * $t *
21
                ($t *($t * ($t * ( $t * $b5 + $b4) + $b3) + $b2) + $b1));
22
        }
23
    }
24
}
25