Basic statistics functions #626
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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 Rorder
function).tiedrank
: asorder
but compensate for ties (comparable to the Rrank
function, or the matlabtiedrank
), which is used fequently in rank based statistics.weighted_mean
: weighted mean---a little trivial, yet useful.median
: (corrected for even-lengthed arrays)var
: variancemad
: median absolute deviance (comparable tomad
in matlab and R)cov_pearson
: pearson covariancecor_pearson
: pearson correlationcov_spearman
: spearman covariancecor_spearman
: spearman correlationcov
: alias forcov_pearson
cor
: alias forcor_pearson
The correlation/covariance functions each have three forms, making them behave similarly to the R cor/cov functions and matlab corr/cov functions.
cor(x, y)
: return a single number giving the correlation between two vectorscor(X, Y)
: return a matrixC
, whereC_ij
gives correlation between columni
inX
and columnj
inY
.cor(X)
: equivalent tocor(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).