We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Currently, the Statistics extension only extends the mean function. The var and std of a StaticMatrix still returns a regular Matrix.
mean
var
std
StaticMatrix
a = @SMatrix(rand(3,4)) mean(a, dims=2) # 3×1 SMatrix var(a, dims=2) # 3×1 Matrix std(a, dims=2) # 3×1 Matrix
I provide a preliminary extension for var and std as follows. Attaching them to the end of StaticArraysStatisticsExt.jl should work.
using Statistics import Statistics: var, std @inline var(a::StaticArray;corrected::Bool=true, mean=nothing, dims=:) = begin m = isnothing(mean) ? Statistics.mean(a; dims=dims) : mean denom = _mean_denom(a, dims) - (corrected ? 1 : 0) _reduce(+, (a.-m).^2, dims) / denom end @inline std(a::SArray; corrected::Bool=true, mean=nothing, dims=:) = sqrt.(var(a; corrected=corrected, mean=mean, dims=dims))
The text was updated successfully, but these errors were encountered:
No branches or pull requests
Currently, the Statistics extension only extends the
mean
function. Thevar
andstd
of aStaticMatrix
still returns a regular Matrix.I provide a preliminary extension for
var
andstd
as follows. Attaching them to the end of StaticArraysStatisticsExt.jl should work.The text was updated successfully, but these errors were encountered: