You are here

public static function PHPExcel_Calculation_Statistical::WEIBULL in Loft Data Grids 6.2

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

* WEIBULL * * Returns the Weibull distribution. Use this distribution in reliability * analysis, such as calculating a device's mean time to failure. * *

Parameters

float $value: * @param float $alpha Alpha Parameter * @param float $beta Beta Parameter * @param boolean $cumulative * @return float *

File

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

Class

PHPExcel_Calculation_Statistical
PHPExcel_Calculation_Statistical

Code

public static function WEIBULL($value, $alpha, $beta, $cumulative) {
  $value = PHPExcel_Calculation_Functions::flattenSingleValue($value);
  $alpha = PHPExcel_Calculation_Functions::flattenSingleValue($alpha);
  $beta = PHPExcel_Calculation_Functions::flattenSingleValue($beta);
  if (is_numeric($value) && is_numeric($alpha) && is_numeric($beta)) {
    if ($value < 0 || $alpha <= 0 || $beta <= 0) {
      return PHPExcel_Calculation_Functions::NaN();
    }
    if (is_numeric($cumulative) || is_bool($cumulative)) {
      if ($cumulative) {
        return 1 - exp(0 - pow($value / $beta, $alpha));
      }
      else {
        return $alpha / pow($beta, $alpha) * pow($value, $alpha - 1) * exp(0 - pow($value / $beta, $alpha));
      }
    }
  }
  return PHPExcel_Calculation_Functions::VALUE();
}