StatsBase.jl
StatsBase.jl copied to clipboard
mean_and_std does not support Tuple but the documentation says so
https://github.com/JuliaStats/StatsBase.jl/blob/08d4b77a4b42ef8cadb67b98da65e7fbd9959e0b/src/moments.jl#L168-L177
Hey everyone! I am new to Julia, and was trying to use the function mean_and_std(). The documentation says that it can take a tuple as input but did not see such a function in the source code. That is why I see an error for this code. using StatsBase X = ones((3,4,5)) mean_and_std(X, dim=(1,2))
And the error is ERROR: MethodError: no method matching mean_and_std(::Array{Float64, 3}; dim=(1, 2))
. It would be a couple of lines of code to implement it. I can create a PR if you think that my understanding is correct.
the issue is the following, in moments.jl
function mean_and_std(x::RealArray, dim::Int; corrected::Bool=true)
m = mean(x, dims=dim)
s = std(x, dims=dim, mean=m, corrected=corrected)
m, s
end
and
function mean_and_std(x::RealArray, w::AbstractWeights, dims::Int;
corrected::DepBool=nothing)
m = mean(x, w, dims=dims)
s = std(x, w, dims, mean=m, corrected=depcheck(:mean_and_std, :corrected, corrected))
m, s
end
They do not allow dim/dims to be as tuples in mean_and_std
. Removing ::Int
may help?
Yes we should deprecate the dim
positional argument and add a dims::Any
keyword argument instead. Would you be willing to make a pull request?
I have created a pull request
any updates?
Maybe there was confusion. I was not doing it. I can only do this in the first week of August. Can update by the 7th of August.
Maybe there was confusion. I was not doing it. I can only do this in the first week of August. Can update by the 7th of August.
Sorry. I meant that I was trying to create a pull request by needing some help.
I closed the pull request because I need a bit more time to understand how to modify the weighted std/var considering the same issue of supporting the tuple type as dimensions.