@@ 2111-2124 (lines=14) @@ | ||
2108 | * accuracy if I can get my head round the mathematics |
|
2109 | * (as described at) http://home.online.no/~pjacklam/notes/invnorm/ |
|
2110 | */ |
|
2111 | public static function LOGINV($probability, $mean, $stdDev) |
|
2112 | { |
|
2113 | $probability = Functions::flattenSingleValue($probability); |
|
2114 | $mean = Functions::flattenSingleValue($mean); |
|
2115 | $stdDev = Functions::flattenSingleValue($stdDev); |
|
2116 | ||
2117 | if ((is_numeric($probability)) && (is_numeric($mean)) && (is_numeric($stdDev))) { |
|
2118 | if (($probability < 0) || ($probability > 1) || ($stdDev <= 0)) { |
|
2119 | return Functions::NAN(); |
|
2120 | } |
|
2121 | ||
2122 | return exp($mean + $stdDev * self::NORMSINV($probability)); |
|
2123 | } |
|
2124 | ||
2125 | return Functions::VALUE(); |
|
2126 | } |
|
2127 | ||
@@ 2577-2593 (lines=17) @@ | ||
2574 | * @param float $stdDev Standard Deviation |
|
2575 | * @return float |
|
2576 | */ |
|
2577 | public static function NORMINV($probability, $mean, $stdDev) |
|
2578 | { |
|
2579 | $probability = Functions::flattenSingleValue($probability); |
|
2580 | $mean = Functions::flattenSingleValue($mean); |
|
2581 | $stdDev = Functions::flattenSingleValue($stdDev); |
|
2582 | ||
2583 | if ((is_numeric($probability)) && (is_numeric($mean)) && (is_numeric($stdDev))) { |
|
2584 | if (($probability < 0) || ($probability > 1)) { |
|
2585 | return Functions::NAN(); |
|
2586 | } |
|
2587 | if ($stdDev < 0) { |
|
2588 | return Functions::NAN(); |
|
2589 | } |
|
2590 | ||
2591 | return (self::inverseNcdf($probability) * $stdDev) + $mean; |
|
2592 | } |
|
2593 | ||
2594 | return Functions::VALUE(); |
|
2595 | } |
|
2596 |