JuliaLang/julia — pull request #626 by dcjones (2012-03-21 18:29:06+00:00)
Title: Basic statistics functions

statistics.jl looked a little bare, so I've implemented some basic functions.

In this commit:

* `order` : gives the permutation that puts an array in order (equivalent to the R `order` function).
* `tiedrank` : as `order` but compensate for ties (comparable to the R `rank` function, or the matlab `tiedrank`), which is used fequently in rank based statistics.
* `weighted_mean` : weighted mean---a little trivial, yet useful.
* `median` : (corrected for even-lengthed arrays)
* `var` : variance
* `mad` : median absolute deviance (comparable to `mad` in matlab and R)
* `cov_pearson` : pearson covariance
* `cor_pearson` : pearson correlation
* `cov_spearman` : spearman covariance
* `cor_spearman` : spearman correlation
* `cov` : alias for `cov_pearson`
* `cor` : alias for `cor_pearson`

The correlation/covariance functions each have three forms, making them behave similarly to the R cor/cov functions and matlab corr/cov functions.

1. `cor(x, y)` : return a single number giving the correlation between two vectors
2. `cor(X, Y)` : return a matrix `C`, where `C_ij` gives correlation between column `i` in `X` and column `j` in `Y`.
3. `cor(X)` : equivalent to `cor(X, X)` (but a bit more efficient).

Next up is to add kendall covariance/correlation, a quantile function, then move on to basic statistical tests (t-test, wilcoxon tests, etc).