|
1 | 1 | # Statistics |
2 | 2 |
|
3 | | -The Statistics module contains basic statistics functionality. |
| 3 | +```@meta |
| 4 | +DocTestSetup = :(using Statistics) |
| 5 | +``` |
4 | 6 |
|
5 | | -!!! note |
6 | | - To use any of the examples described below, run `using Statistics` and then the code from the example. |
| 7 | +The Statistics module contains basic statistics functionality: mean, median, quantiles, |
| 8 | +standard deviation, variance, skewness, kurtosis, correlation and covariance. |
| 9 | +Statistics can be weighted, and several weights types are distinguished to apply appropriate |
| 10 | +corrections where necessary. |
| 11 | + |
| 12 | +## Mean, median and quantiles |
| 13 | + |
| 14 | +```@docs |
| 15 | +Statistics.mean |
| 16 | +Statistics.mean! |
| 17 | +Statistics.median |
| 18 | +Statistics.median! |
| 19 | +Statistics.middle |
| 20 | +Statistics.quantile |
| 21 | +Statistics.quantile! |
| 22 | +``` |
| 23 | + |
| 24 | +## Moments |
7 | 25 |
|
8 | 26 | ```@docs |
9 | 27 | Statistics.std |
10 | 28 | Statistics.stdm |
11 | 29 | Statistics.var |
12 | 30 | Statistics.varm |
| 31 | +Statistics.skewness |
| 32 | +Statistics.kurtosis |
| 33 | +``` |
| 34 | + |
| 35 | +## Correlation and covariance |
| 36 | + |
| 37 | +```@docs |
13 | 38 | Statistics.cor |
14 | 39 | Statistics.cov |
15 | | -Statistics.mean! |
16 | | -Statistics.mean |
17 | | -Statistics.median! |
18 | | -Statistics.median |
19 | | -Statistics.middle |
20 | | -Statistics.quantile! |
21 | | -Statistics.quantile |
| 40 | +``` |
| 41 | + |
| 42 | +## Weights types |
| 43 | + |
| 44 | +Four statistical weights types are provided which inherit from the `AbstractWeights` type: |
| 45 | + |
| 46 | +- `Weights` is a generic type for arbitary weights. Using this type will trigger an error |
| 47 | + with functions which rely on assumptions about a particular definition of weights. |
| 48 | +- `AnalyticWeights` describe the relative importance for each observation. |
| 49 | + These weights may also be referred to as reliability weights, precision weights |
| 50 | + or inverse variance weights. These are typically used when the observations |
| 51 | + are aggregate values (e.g. averages) with differing variances. |
| 52 | +- `FrequencyWeights` describe the number of times (or frequency) each observation |
| 53 | + was observed. These weights may also be referred to as case weights or repeat weights. |
| 54 | +- `ProbabilityWeights` represent the inverse of the sampling probability |
| 55 | + for each observation, providing a correction mechanism for under- or over-sampling |
| 56 | + certain population groups. These weights may also be referred to as sampling weights. |
| 57 | + |
| 58 | +The choice of weights impacts how bias is corrected in several methods. |
| 59 | +See the [`var`](@ref), [`std`](@ref), [`cov`](@ref) and [`quantile`](@ref) |
| 60 | +docstrings for more details. |
| 61 | + |
| 62 | +Short-hand constructors `weights`, `aweights`, `fweights` and `pweights` |
| 63 | +are provided for convenience. |
| 64 | + |
| 65 | +!!! note |
| 66 | + - The weight vector is a light-weight wrapper of the input vector. |
| 67 | + The input vector is NOT copied during construction. |
| 68 | + - The weight vector maintains the sum of weights, which is computed upon construction. |
| 69 | + If the value of the sum is pre-computed, one can supply it as the second argument |
| 70 | + to the constructor and save the time of computing the sum again. |
| 71 | + |
| 72 | +```@docs |
| 73 | +Statistics.AbstractWeights |
| 74 | +Statistics.Weights |
| 75 | +Statistics.AnalyticWeights |
| 76 | +Statistics.FrequencyWeights |
| 77 | +Statistics.ProbabilityWeights |
| 78 | +Statistics.weights |
| 79 | +Statistics.aweights |
| 80 | +Statistics.fweights |
| 81 | +Statistics.pweights |
| 82 | +``` |
| 83 | + |
| 84 | +```@meta |
| 85 | +DocTestSetup = nothing |
22 | 86 | ``` |
0 commit comments