Skip to content
New issue

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

Fix mean_and_var and mean_and_std docstring signature #836

Merged
merged 2 commits into from Oct 7, 2022

Conversation

bowenszhu
Copy link
Contributor

The default value for the argument corrected in the docstring signature of mean_and_var and mean_and_std is false, but it is actually true in the code.

StatsBase.jl/src/moments.jl

Lines 153 to 165 in a0e6f1e

"""
mean_and_var(x, [w::AbstractWeights], [dim]; corrected=false) -> (mean, var)
Return the mean and variance of a real-valued array `x`, optionally over a dimension
`dim`, as a tuple. Observations in `x` can be weighted using weight vector `w`.
Finally, bias correction is be applied to the variance calculation if `corrected=true`.
See [`var`](@ref) documentation for more details.
"""
function mean_and_var(A::RealArray; corrected::Bool=true)
m = mean(A)
v = varm(A, m; corrected=corrected)
m, v
end

StatsBase.jl/src/moments.jl

Lines 167 to 180 in a0e6f1e

"""
mean_and_std(x, [w::AbstractWeights], [dim]; corrected=false) -> (mean, std)
Return the mean and standard deviation of a real-valued array `x`, optionally
over a dimension `dim`, as a tuple. A weighting vector `w` can be specified
to weight the estimates. Finally, bias correction is applied to the
standard deviation calculation if `corrected=true`.
See [`std`](@ref) documentation for more details.
"""
function mean_and_std(A::RealArray; corrected::Bool=true)
m = mean(A)
s = stdm(A, m; corrected=corrected)
m, s
end

Copy link
Member

@nalimilan nalimilan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks! The default was changed a long time ago and it looks like we missed some occurrences.

@nalimilan nalimilan merged commit 39d0433 into JuliaStats:master Oct 7, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants