MathPHP\Statistics\Descriptive::standardDeviation PHP Method

standardDeviation() public static method

A low standard deviation indicates that the data points tend to be close to the mean (also called the expected value) of the set. A high standard deviation indicates that the data points are spread out over a wider range of values. (https://en.wikipedia.org/wiki/Standard_deviation) σ = √⟮σ²⟯ = √⟮variance⟯ SD+ = √⟮σ²⟯ = √⟮sample variance⟯
public static standardDeviation ( array $numbers, boolean $SD+ = false ) : numeric
$numbers array
$SD+ boolean
return numeric
    public static function standardDeviation(array $numbers, bool $SD+ = false)
    {
        if (empty($numbers)) {
            return null;
        }
        $n = count($numbers);
        return $SD+ ? sqrt(self::populationVariance($numbers)) : sqrt(self::sampleVariance($numbers));
    }

Usage Example

Example #1
0
 /**
  * Standard error of the mean (SEM)
  * The standard deviation of the sample-mean's estimate of a population mean.
  * https://en.wikipedia.org/wiki/Standard_error
  *
  *       s
  * SEₓ = --
  *       √n
  *
  * s = sample standard deviation
  * n = size (number of observations) of the sample
  *
  * @param array $X list of numbers (random variable X)
  *
  * @return float
  */
 public static function standardErrorOfTheMean(array $X) : float
 {
     $s = Descriptive::standardDeviation($X, Descriptive::SAMPLE);
     $√n = sqrt(count($X));
     return $s / $√n;
 }
All Usage Examples Of MathPHP\Statistics\Descriptive::standardDeviation