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
 /**
  * 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;
 }
Beispiel #2
0
 /**
  * Sample correlation coefficient
  * Pearson product-moment correlation coefficient (PPMCC or PCC or Pearson's r)
  *
  * A normalized measure of the linear correlation between two variables X and Y,
  * giving a value between +1 and −1 inclusive, where 1 is total positive correlation,
  * 0 is no correlation, and −1 is total negative correlation.
  * It is widely used in the sciences as a measure of the degree of linear dependence
  * between two variables.
  * https://en.wikipedia.org/wiki/Pearson_product-moment_correlation_coefficient
  *
  * The correlation coefficient of two variables in a data sample is their covariance
  * divided by the product of their individual standard deviations.
  *
  *          Sxy
  * rxy = ----------
  *         sx sy
  *
  *  Sxy is the sample covariance
  *  σx is the sample standard deviation of X
  *  σy is the sample standard deviation of Y
  *
  * @param array $X values for random variable X
  * @param array $Y values for random variable Y
  *
  * @return number
  */
 public static function sampleCorrelationCoefficient(array $X, array $Y)
 {
     $Sxy = self::sampleCovariance($X, $Y);
     $sx = Descriptive::standardDeviation($X, Descriptive::SAMPLE);
     $sy = Descriptive::standardDeviation($Y, Descriptive::SAMPLE);
     return $Sxy / ($sx * $sy);
 }