Basic statistics functions#626
Conversation
|
The select function was defined over AbstractVector, so I did the same with median, but there was no need for that it turns out. |
Basic statistics functions
|
Thank you, this is great! |
|
I think maybe we both mixed them up. :) My order was incorrect, yours is correct. But my tiedrank was correct. They should do two different things: |
|
I assume the fix is to use |
This undocumented function does not actually ensure that the result is mutable. Use the same approach as `Base.copymutable`, which relies only on public API.
Stdlib: SparseArrays URL: https://github.com/JuliaSparse/SparseArrays.jl.git Stdlib branch: main Julia branch: master Old commit: f3610c0 New commit: 6d072a8 Julia version: 1.13.0-DEV SparseArrays version: 1.12.0(Does not match) Bump invoked by: @IanButterworth Powered by: [BumpStdlibs.jl](https://github.com/JuliaLang/BumpStdlibs.jl) Diff: JuliaSparse/SparseArrays.jl@f3610c0...6d072a8 ``` $ git log --oneline f3610c0..6d072a8 6d072a8 Lazily init cholmod (#626) 8ff11da fix libsuitesparseconfig bug (#625) fac1548 lazily init cholmod 75eaa18 fix libsuitesparseconfig bug 7b6e810 Use `libsuitesparseconfig` from JLL (#620) b225a85 Clarify pros, cons and limitations of Cholesky and LDLt (#621) 3d42644 Update index.md (#623) 16bbcbc 5-term mul! with Diagonal (#603) d050b1b Relax `eltype` in `Diagonal` `ldiv!`/`rdiv!` (#616) 4968cff `ldiv!` for `Diagonal` and a sparse vector (#613) 5062034 Fix `issymmetric` for matrices with empty columns (#606) 9a46561 Replace `v == zero(v)` with `_iszero` (#610) ``` Co-authored-by: IanButterworth <1694067+IanButterworth@users.noreply.github.com>
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 Rorderfunction).tiedrank: asorderbut compensate for ties (comparable to the Rrankfunction, 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 tomadin matlab and R)cov_pearson: pearson covariancecor_pearson: pearson correlationcov_spearman: spearman covariancecor_spearman: spearman correlationcov: alias forcov_pearsoncor: alias forcor_pearsonThe 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_ijgives correlation between columniinXand columnjinY.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).