@@ 2197-2212 (lines=16) @@ | ||
2194 | * accuracy if I can get my head round the mathematics |
|
2195 | * (as described at) http://home.online.no/~pjacklam/notes/invnorm/ |
|
2196 | */ |
|
2197 | public static function LOGINV($probability, $mean, $stdDev) |
|
2198 | { |
|
2199 | $probability = Functions::flattenSingleValue($probability); |
|
2200 | $mean = Functions::flattenSingleValue($mean); |
|
2201 | $stdDev = Functions::flattenSingleValue($stdDev); |
|
2202 | ||
2203 | if ((is_numeric($probability)) && (is_numeric($mean)) && (is_numeric($stdDev))) { |
|
2204 | if (($probability < 0) || ($probability > 1) || ($stdDev <= 0)) { |
|
2205 | return Functions::NAN(); |
|
2206 | } |
|
2207 | ||
2208 | return exp($mean + $stdDev * self::NORMSINV($probability)); |
|
2209 | } |
|
2210 | ||
2211 | return Functions::VALUE(); |
|
2212 | } |
|
2213 | ||
2214 | /** |
|
2215 | * LOGNORMDIST. |
|
@@ 2685-2703 (lines=19) @@ | ||
2682 | * |
|
2683 | * @return float |
|
2684 | */ |
|
2685 | public static function NORMINV($probability, $mean, $stdDev) |
|
2686 | { |
|
2687 | $probability = Functions::flattenSingleValue($probability); |
|
2688 | $mean = Functions::flattenSingleValue($mean); |
|
2689 | $stdDev = Functions::flattenSingleValue($stdDev); |
|
2690 | ||
2691 | if ((is_numeric($probability)) && (is_numeric($mean)) && (is_numeric($stdDev))) { |
|
2692 | if (($probability < 0) || ($probability > 1)) { |
|
2693 | return Functions::NAN(); |
|
2694 | } |
|
2695 | if ($stdDev < 0) { |
|
2696 | return Functions::NAN(); |
|
2697 | } |
|
2698 | ||
2699 | return (self::inverseNcdf($probability) * $stdDev) + $mean; |
|
2700 | } |
|
2701 | ||
2702 | return Functions::VALUE(); |
|
2703 | } |
|
2704 | ||
2705 | /** |
|
2706 | * NORMSDIST. |