How to create cumulative normal distribution in PHP

Can someone tell me how to get the equivalent of Excel function (NORMDIST (TRUE)) in PHP?

I tried the PECL statistics package (stats_dens_normal), but this seems to create a probability mass function (equivalent to using NORMDIST in Excel with cumulative dialing in FALSE).

So, I want to use PHP to get the Excel equivalent NORMDIST (x, mean, standard_dev TRUE).

Any help greatly appreciated!

+3
source share
1 answer

Here is the php method for approximate cumulative normal distribution:

http://abtester.com/calculator/

zscore . excel NORMDIST.

function cumnormdist($x)
{
  $b1 =  0.319381530;
  $b2 = -0.356563782;
  $b3 =  1.781477937;
  $b4 = -1.821255978;
  $b5 =  1.330274429;
  $p  =  0.2316419;
  $c  =  0.39894228;

  if($x >= 0.0) {
      $t = 1.0 / ( 1.0 + $p * $x );
      return (1.0 - $c * exp( -$x * $x / 2.0 ) * $t *
      ( $t *( $t * ( $t * ( $t * $b5 + $b4 ) + $b3 ) + $b2 ) + $b1 ));
  }
  else {
      $t = 1.0 / ( 1.0 - $p * $x );
      return ( $c * exp( -$x * $x / 2.0 ) * $t *
      ( $t *( $t * ( $t * ( $t * $b5 + $b4 ) + $b3 ) + $b2 ) + $b1 ));
    }
}
+9

Source: https://habr.com/ru/post/1777469/


All Articles