Statistics¶
Mean, Standard Deviation and Variance¶
-
mean(a…)¶ Computes the arithmetic mean of \(a\), a dataset of length \(n\). The arithmetic mean, or sample mean, is denoted by \(\hat\mu\) and defined as,
\[\hat\mu = {1 \over N} \sum a_i\]where \(a_i\) are the elements of the dataset \(a\).
>>> mean(1, 3, 6, 10) = 5 >>> mean(1, 3, 7, 11, 13, 17) = 26/3
-
var(a…, ddof=1)¶ Computes the variance of \(a\), a dataset of length \(n\). The variance is denoted by \(\hat\sigma^2\) and defined as,
\[\hat\sigma^2 = \frac{1}{N - \text{ddof}} \sum (a_i - \hat\mu)^2\]where \(a_i\) are the elements of the dataset \(a\) and
ddofdenotes the degrees of freedom. Aliases:variance>>> var(1, 3, 7, 11, 13, 17) = 562/15 >>> variance(1, 3, 7, 11, 13, 17, ddof=2) = 281/6
-
sd(a…, ddof=1)¶ Computes the standard deviation of \(a\), a dataset of length \(n\). The standard deviation is denoted by \(\hat\sigma\) and defined as the square root of the variance. Aliases:
std,stdev>>> sd(1, 3, 7, 11, 13, 17) = 6.121002096606949 >>> std(1, 3, 7, 11, 13, 17, ddof=2) = 6.843488389215937
-
tss(a…)¶ Computes the total sum of squares (TSS) of \(a\), a dataset of length \(n\). The TSS defined as,
\[\text{TSS} = \sum (a_i - \hat\mu)^2\]where \(a_i\) are the elements of the dataset \(a\) and \(\hat\mu\) denotes the arithmetic mean of \(a\).
>>> tss(1, 3, 7, 11, 13, 17) = 562/3
Absolute deviation¶
-
absdev(a…)¶ Computes the absolute deviation from the mean of \(a\), a dataset of length \(n\). The absolute deviation from the mean is defined as,
\[\text{absdev} = \frac{1}{N} \sum |a_i - \hat\mu|\]where \(a_i\) are the elements of the dataset \(a\) and \(\hat\mu\) denotes the arithmetic mean of \(a\).
>>> absdev(1, 3, 7, 11, 13, 17) = 5
Higher moments (skewness and kurtosis)¶
-
skew(a…)¶ Computes the skewness of \(a\), a dataset of length \(n\). The skewness is defined as,
\[\text{skew} = \frac{1}{N} \sum \left( \frac{a_i - \hat\mu}{\hat\sigma} \right)^3\]where \(a_i\) are the elements of the dataset \(a\), \(\hat\mu\) denotes the arithmetic mean of \(a\), and \(\hat\sigma\) denotes the standard deviation of \(a\).
>>> skew(1, 3, 7, 11, 13, 17) = 0.02583976940771193
-
kurtosis(a…)¶ Computes the kurtosis of \(a\), a dataset of length \(n\). The kurtosis is defined as,
\[\text{kurtosis} = \left( \frac{1}{N} \sum \left( \frac{a_i - \hat\mu}{\hat\sigma} \right)^4 \right) - 3\]where \(a_i\) are the elements of the dataset \(a\), \(\hat\mu\) denotes the arithmetic mean of \(a\), and \(\hat\sigma\) denotes the standard deviation of \(a\). Aliases:
kurt>>> kurtosis(1, 3, 7, 11, 13, 17) = -1.848508546413208 >>> kurt(1, 3, 7, 11, 13, 17) = -1.848508546413208
Autocorrelation¶
-
lag1(a…)¶ Computes the lag-1 autocorrelation of \(a\), a dataset of length \(n\). The lag-1 autocorrelation is defined as,
\[l_1 = \frac{\sum_{i=2}^{n} (a_i - \hat\mu)(a_{i-1} - \hat\mu)}{\sum_{i=1}^{n} (a_i - \hat\mu)(a_i - \hat\mu)}\]where \(a_i\) are the elements of the dataset \(a\), \(\hat\mu\) denotes the arithmetic mean of \(a\), and \(\hat\sigma\) denotes the standard deviation of \(a\). Aliases:
autocorr>>> lag1(1, 3, 7, 11, 13, 17) = 857/1686 = 0.5083036773428232 >>> autocorr(1, 3, 7, 11, 13, 17) = 857/1686 = 0.5083036773428232
Maximum and Minimum Values¶
-
max(a…)¶ Computes the maximum value of \(a\), a dataset of length \(n\).
>>> max(1, 3, 7, 11, 13, 17) = 17 >>> max(-1, -3, -7, -11, -13, -17) = -1
-
min(a…)¶ Computes the minimum value of \(a\), a dataset of length \(n\).
>>> min(1, 3, 7, 11, 13, 17) = 17 >>> min(-1, -3, -7, -11, -13, -17) = -1
-
argmax(a…)¶ Computes the index of the maximum value of \(a\), a dataset of length \(n\). Aliases:
max_index>>> argmax(1, 3, 7, 11, 13, 17) = 5 >>> max_index(-1, -3, -7, -11, -13, -17) = 0
-
argmin(a…)¶ Computes the index of the minimum value of \(a\), a dataset of length \(n\). Aliases:
min_index>>> argmin(1, 3, 7, 11, 13, 17) = 0 >>> min_index(-1, -3, -7, -11, -13, -17) = 5