MathPHP\Statistics\Correlation::populationCorrelationCoefficient PHP Метод

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

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. cov(X,Y) ρxy = ---------- σx σy conv(X,Y) is the population covariance σx is the population standard deviation of X σy is the population standard deviation of Y
public static populationCorrelationCoefficient ( array $X, array $Y ) : number
$X array values for random variable X
$Y array values for random variable Y
Результат number
    public static function populationCorrelationCoefficient(array $X, array $Y)
    {
        $cov⟮X,Y⟯ = self::populationCovariance($X, $Y);
        $σx = Descriptive::standardDeviation($X, true);
        $σy = Descriptive::standardDeviation($Y, true);
        return $cov⟮X,Y⟯ / ($σx * $σy);
    }