diff --git a/Math/Statistic/Average.php b/Math/Statistic/Average.php index 2449fc4bc..ff046ad1b 100644 --- a/Math/Statistic/Average.php +++ b/Math/Statistic/Average.php @@ -172,6 +172,8 @@ final class Average * * Example: ([1, 2, 2, 3, 4, 4, 2]) * + * @latex \mu = mean = \frac{1}{n}\sum_{i=1}^{n}a_i + * * @param array $values Values * @param int $offset Offset for outlier * diff --git a/Math/Statistic/Correlation.php b/Math/Statistic/Correlation.php index d3b19b9ad..6d38faecf 100755 --- a/Math/Statistic/Correlation.php +++ b/Math/Statistic/Correlation.php @@ -39,6 +39,8 @@ final class Correlation * * Example: ([4, 5, 9, 1, 3], [4, 5, 9, 1, 3]) * + * @latex \rho_{XY} = \frac{cov(X, Y)}{\sigma_X \sigma_Y} + * * @param array $x Values * @param array $y Values * @@ -56,6 +58,8 @@ final class Correlation * * Example: ([4, 5, 9, 1, 3], [4, 5, 9, 1, 3]) * + * @latex \rho_{XY} = \frac{cov(X, Y)}{\sigma_X \sigma_Y} + * * @param array $x Values * @param array $y Values * diff --git a/Math/Statistic/MeasureOfDispersion.php b/Math/Statistic/MeasureOfDispersion.php index 999fbc16d..e9e3356b5 100644 --- a/Math/Statistic/MeasureOfDispersion.php +++ b/Math/Statistic/MeasureOfDispersion.php @@ -212,7 +212,7 @@ final class MeasureOfDispersion * * Example: ([4, 5, 9, 1, 3], [4, 5, 9, 1, 3]) * - * @latex \sigma_{XY} = cov(X, Y) = \sum_{i = 1}^{N}\frac{\left(x_{i} - \bar{X}\right) \left(y_{i} - \bar{Y}\right)}{N - 1} + * @latex cov(X,Y) = \frac{1}{N} \sum_{i = 1}^{N}\left(x_{i} - \bar{X}\right)\left(y_{i} - \bar{Y}\right) * * @param array $x Values * @param array $y Values @@ -255,7 +255,7 @@ final class MeasureOfDispersion * * Example: ([4, 5, 9, 1, 3], [4, 5, 9, 1, 3]) * - * @latex \sigma_{XY} = cov(X, Y) = \sum_{i = 1}^{N}\frac{\left(x_{i} - \bar{X}\right) \left(y_{i} - \bar{Y}\right)}{N - 1} + * @latex cov(X,Y) = \frac{1}{N - 1} \sum_{i = 1}^{N}\left(x_{i} - \bar{X}\right)\left(y_{i} - \bar{Y}\right) * * @param array $x Values * @param array $y Values diff --git a/Math/Stochastic/Distribution/ChiSquaredDistribution.php b/Math/Stochastic/Distribution/ChiSquaredDistribution.php index c5dd12e2e..bf7651b48 100644 --- a/Math/Stochastic/Distribution/ChiSquaredDistribution.php +++ b/Math/Stochastic/Distribution/ChiSquaredDistribution.php @@ -77,6 +77,8 @@ final class ChiSquaredDistribution /** * Test hypthesis. * + * Goodness of fit test. + * * @param array $dataset Values * @param array $expected Expected values based on probability * @param float $significance Significance diff --git a/Utils/ArrayUtils.php b/Utils/ArrayUtils.php index 0fa497228..628107e8b 100644 --- a/Utils/ArrayUtils.php +++ b/Utils/ArrayUtils.php @@ -75,6 +75,20 @@ final class ArrayUtils return $data; } + /** + * Calculate the range of the array + * + * @param int[]|float[] $values Numeric values + * + * @return int|float Range of the array + * + * @since 1.0.0 + */ + public static function range(array $values) : int|float + { + return \max($values) - \min($values); + } + /** * Set element in array by path *