StatsBase.jl
StatsBase.jl copied to clipboard
Compute statistics along dimensions
It is useful to compute certain statistics along specific dimensions. I open this thread to derive the development along this line.
- [ ]
skewness - [ ]
kurtosis - [ ]
moment - [ ]
entropy - [ ]
geomean - [ ]
harmmean - [ ]
variation - [ ]
sem
Some other functions like mode and quantile require more sophisticated data structure to compute, and thus not included in this list. We may look at those in future.
+1 if you mean something like this:
StatsBase.trimmean{T}(v::AbstractArray{T}, p, region) = mapslices(x->trimmean(x,p), v, region)
Any progress on this?
Now that Julia provides these, it is probably be better to use e.g. skewness.(eachrow(x)) and skewness.(eachcol(x)). The dims=1/dims=2 approach requires adjusting lots of methods and is less explicit.
It would be nice to have functions like skewness(A; dims) taking a dims keyword to reduce over, where A can be a general N-dimensional Array. Any plans to implement this?
@cossio There's a PR to add a generic eachslice iterator to Base: https://github.com/JuliaLang/julia/pull/32310; it's been under review for a while but there's recent activity...
This is now merged, time to close this issue?
skewness(rand(10,10), dims=1) doesn't work on 1.9rc1 and latest StatsBase
@jamblejoe but you can use eachslice on julia 1.8 to achieve the same:
julia> skewness.(eachslice(rand(10,10), dims=1))
10-element Vector{Float64}:
-0.357654736525527
-0.06636393783605732
-0.20782459433865907
1.25151036890323
0.13408296667729347
-0.4302398373636257
-0.14363707095203634
-0.00889806440269636
-0.6370034546305223
0.5832296811450159
@bjarthur works thanks! Can be closed from my side