You are here

public static function PHPExcel_Calculation_Statistical::NORMDIST in Loft Data Grids 7.2

Same name and namespace in other branches
  1. 6.2 vendor/phpoffice/phpexcel/Classes/PHPExcel/Calculation/Statistical.php \PHPExcel_Calculation_Statistical::NORMDIST()

* NORMDIST * * Returns the normal distribution for the specified mean and standard deviation. This * function has a very wide range of applications in statistics, including hypothesis * testing. * *

Parameters

float $value: * @param float $mean Mean Value * @param float $stdDev Standard Deviation * @param boolean $cumulative * @return float *

1 call to PHPExcel_Calculation_Statistical::NORMDIST()
PHPExcel_Calculation_Statistical::NORMSDIST in vendor/phpoffice/phpexcel/Classes/PHPExcel/Calculation/Statistical.php
* NORMSDIST * * Returns the standard normal cumulative distribution function. The distribution has * a mean of 0 (zero) and a standard deviation of one. Use this function in place of a * table of standard normal curve areas. * *

File

vendor/phpoffice/phpexcel/Classes/PHPExcel/Calculation/Statistical.php, line 2518

Class

PHPExcel_Calculation_Statistical
PHPExcel_Calculation_Statistical

Code

public static function NORMDIST($value, $mean, $stdDev, $cumulative) {
  $value = PHPExcel_Calculation_Functions::flattenSingleValue($value);
  $mean = PHPExcel_Calculation_Functions::flattenSingleValue($mean);
  $stdDev = PHPExcel_Calculation_Functions::flattenSingleValue($stdDev);
  if (is_numeric($value) && is_numeric($mean) && is_numeric($stdDev)) {
    if ($stdDev < 0) {
      return PHPExcel_Calculation_Functions::NaN();
    }
    if (is_numeric($cumulative) || is_bool($cumulative)) {
      if ($cumulative) {
        return 0.5 * (1 + PHPExcel_Calculation_Engineering::_erfVal(($value - $mean) / ($stdDev * sqrt(2))));
      }
      else {
        return 1 / (SQRT2PI * $stdDev) * exp(0 - pow($value - $mean, 2) / (2 * ($stdDev * $stdDev)));
      }
    }
  }
  return PHPExcel_Calculation_Functions::VALUE();
}