MathPHP\Statistics\Descriptive::variance PHP Метод

variance() публичный статический Метод

Variance measures how far a set of numbers are spread out. A variance of zero indicates that all the values are identical. Variance is always non-negative: a small variance indicates that the data points tend to be very close to the mean (expected value) and hence to each other. A high variance indicates that the data points are very spread out around the mean and from each other. (https://en.wikipedia.org/wiki/Variance) ∑⟮xᵢ - μ⟯² σ² = ---------- ν Generalized method that allows setting the degrees of freedom. For population variance, set d.f. (ν) to n For sample variance, set d.f (ν) to n - 1 Or use popluationVariance or sampleVaraince covenience methods. μ is the population mean ν is the degrees of freedom, which usually is the number of numbers in the population set or n - 1 for sample set.
public static variance ( array $numbers, integer ) : numeric
$numbers array
integer degrees of freedom
Результат numeric
    public static function variance(array $numbers, int $ν)
    {
        if (empty($numbers)) {
            return null;
        }
        if ($ν <= 0) {
            throw new Exception\OutOfBoundsException('Degrees of freedom must be > 0');
        }
        $∑⟮xᵢ − μ⟯² = RandomVariable::sumOfSquaresDeviations($numbers);
        return $∑⟮xᵢ − μ⟯² / $ν;
    }