Search moodle.org's
Developer Documentation

See Release Notes
Long Term Support Release

  • Bug fixes for general core bugs in 4.1.x will end 13 November 2023 (12 months).
  • Bug fixes for security issues in 4.1.x will end 10 November 2025 (36 months).
  • PHP version: minimum PHP 7.4.0 Note: minimum PHP version has increased since Moodle 4.0. PHP 8.0.x is supported too.
   1  <?php
   2  
   3  namespace PhpOffice\PhpSpreadsheet\Calculation\Statistical;
   4  
   5  class StandardDeviations
   6  {
   7      /**
   8       * STDEV.
   9       *
  10       * Estimates standard deviation based on a sample. The standard deviation is a measure of how
  11       *        widely values are dispersed from the average value (the mean).
  12       *
  13       * Excel Function:
  14       *        STDEV(value1[,value2[, ...]])
  15       *
  16       * @param mixed ...$args Data values
  17       *
  18       * @return float|string The result, or a string containing an error
  19       */
  20      public static function STDEV(...$args)
  21      {
  22          $result = Variances::VAR(...$args);
  23          if (!is_numeric($result)) {
  24              return $result;
  25          }
  26  
  27          return sqrt((float) $result);
  28      }
  29  
  30      /**
  31       * STDEVA.
  32       *
  33       * Estimates standard deviation based on a sample, including numbers, text, and logical values
  34       *
  35       * Excel Function:
  36       *        STDEVA(value1[,value2[, ...]])
  37       *
  38       * @param mixed ...$args Data values
  39       *
  40       * @return float|string
  41       */
  42      public static function STDEVA(...$args)
  43      {
  44          $result = Variances::VARA(...$args);
  45          if (!is_numeric($result)) {
  46              return $result;
  47          }
  48  
  49          return sqrt((float) $result);
  50      }
  51  
  52      /**
  53       * STDEVP.
  54       *
  55       * Calculates standard deviation based on the entire population
  56       *
  57       * Excel Function:
  58       *        STDEVP(value1[,value2[, ...]])
  59       *
  60       * @param mixed ...$args Data values
  61       *
  62       * @return float|string
  63       */
  64      public static function STDEVP(...$args)
  65      {
  66          $result = Variances::VARP(...$args);
  67          if (!is_numeric($result)) {
  68              return $result;
  69          }
  70  
  71          return sqrt((float) $result);
  72      }
  73  
  74      /**
  75       * STDEVPA.
  76       *
  77       * Calculates standard deviation based on the entire population, including numbers, text, and logical values
  78       *
  79       * Excel Function:
  80       *        STDEVPA(value1[,value2[, ...]])
  81       *
  82       * @param mixed ...$args Data values
  83       *
  84       * @return float|string
  85       */
  86      public static function STDEVPA(...$args)
  87      {
  88          $result = Variances::VARPA(...$args);
  89          if (!is_numeric($result)) {
  90              return $result;
  91          }
  92  
  93          return sqrt((float) $result);
  94      }
  95  }