From d47c4e8ca983c2e8cc466c634c8b7133f55a4e38 Mon Sep 17 00:00:00 2001 From: Dennis Eichhorn Date: Fri, 9 Sep 2022 21:01:11 +0200 Subject: [PATCH] continue statistics documentation writing --- math/statistics.md | 75 +++++++++++++++++++++++++++++++++++++++------- 1 file changed, 65 insertions(+), 10 deletions(-) diff --git a/math/statistics.md b/math/statistics.md index 1b407a5..6fd0134 100644 --- a/math/statistics.md +++ b/math/statistics.md @@ -4,24 +4,50 @@ ### Range -```php -ArrayUtils::range($values); -``` - $$ range = max(values) - min(values) $$ -### Mean (arithmetic) - ```php -Average::mean($values); +ArrayUtils::range($values); ``` +### Mean (arithmetic) + $$ -mean = \frac{1}{n}\sum_{i=1}^{n}a_i +\mu = mean = \bar{X} = \frac{1}{n}\sum_{i=1}^{n}a_i $$ +```php +Average::arithmeticMean($values); +``` + +### Variance + +$$ +\sigma^{2} = Var(X) = \frac{1}{N} \sum_{i = 1}^{N}\left(x_{i} - \bar{X}\right)^{2} +$$ + +```php +MeasureOfDispersion::empiricalVariance($x, $y); +MeasureOfDispersion::sampleVariance($x, $y); +``` + +> The sample variance calculates with N - 1 + +### Covariance + +$$ +cov(X,Y) = \frac{1}{N} \sum_{i = 1}^{N}\left(x_{i} - \bar{X}\right)\left(y_{i} - \bar{Y}\right) +$$ + +```php +MeasureOfDispersion::empiricalCovariance($x, $y); +MeasureOfDispersion::sampleCovariance($x, $y); +``` + +> The sample covariance calculates with N - 1 + ## Variable types Variables are characteristics (i.e. height, weight) @@ -63,18 +89,47 @@ It is possible to transfrom variables: #### Goodness of fit test +This tests if observed values follows expected/known proportions (e.g. distributions.) + +* H0: The observation follows the expected frequency/distribution (i.e. normal distribution) +* H1: The observation doesn't follow the expected frequency/distribution (i.e. normal distribution) + +> If H0 can be discarded or not depends on the significance (p-value). + +```php +ChiSquaredDistribution::testHypothesis($observed, $expected, $significance = 0.05, $degreesOfFreedom = 0); +``` + #### Test of independence +This tests if there is a relationship between two categorical variables. + +* H0: The variables are independent (there is no relationship between them) +* H1: The variables are dependent (there is a relationship between them) + ### t-test #### One sample +This tests if the observed mean is different from a expected mean. + #### Two samples -#### Paired samples +This tests if the observed mean or median is different from two samples. ### Correlation #### Pearson correlation -#### Spearman's rank correlation \ No newline at end of file +Measures how two variables are related to each other (do they perform similarly, opposite or not related at all). + +$$ +\rho_{XY} = \frac{cov(X, Y)}{\sigma_X \sigma_Y} +$$ + +```php +Correlation::bravaisPersonCorrelationCoefficientPopulation($x, $y); +Correlation::bravaisPersonCorrelationCoefficientSample($x, $y); +``` + +> The sample correlation calculates with N - 1