Search moodle.org's
Developer Documentation

See Release Notes

  • Bug fixes for general core bugs in 4.0.x will end 8 May 2023 (12 months).
  • Bug fixes for security issues in 4.0.x will end 13 November 2023 (18 months).
  • PHP version: minimum PHP 7.3.0 Note: the minimum PHP version has increased since Moodle 3.10. PHP 7.4.x is also supported.

Differences Between: [Versions 400 and 401] [Versions 400 and 402] [Versions 400 and 403]

   1  <?php
   2  
   3  namespace PhpOffice\PhpSpreadsheet\Calculation\Statistical\Distributions;
   4  
   5  use PhpOffice\PhpSpreadsheet\Calculation\Exception;
   6  use PhpOffice\PhpSpreadsheet\Calculation\Functions;
   7  
   8  class Fisher
   9  {
  10      /**
  11       * FISHER.
  12       *
  13       * Returns the Fisher transformation at x. This transformation produces a function that
  14       *        is normally distributed rather than skewed. Use this function to perform hypothesis
  15       *        testing on the correlation coefficient.
  16       *
  17       * @param mixed $value Float value for which we want the probability
  18       *
  19       * @return float|string
  20       */
  21      public static function distribution($value)
  22      {
  23          $value = Functions::flattenSingleValue($value);
  24  
  25          try {
  26              DistributionValidations::validateFloat($value);
  27          } catch (Exception $e) {
  28              return $e->getMessage();
  29          }
  30  
  31          if (($value <= -1) || ($value >= 1)) {
  32              return Functions::NAN();
  33          }
  34  
  35          return 0.5 * log((1 + $value) / (1 - $value));
  36      }
  37  
  38      /**
  39       * FISHERINV.
  40       *
  41       * Returns the inverse of the Fisher transformation. Use this transformation when
  42       *        analyzing correlations between ranges or arrays of data. If y = FISHER(x), then
  43       *        FISHERINV(y) = x.
  44       *
  45       * @param mixed $probability Float probability at which you want to evaluate the distribution
  46       *
  47       * @return float|string
  48       */
  49      public static function inverse($probability)
  50      {
  51          $probability = Functions::flattenSingleValue($probability);
  52  
  53          try {
  54              DistributionValidations::validateFloat($probability);
  55          } catch (Exception $e) {
  56              return $e->getMessage();
  57          }
  58  
  59          return (exp(2 * $probability) - 1) / (exp(2 * $probability) + 1);
  60      }
  61  }