Trying to follow a simple example from documentation for mean(x, weights(w)) (https://juliastats.org/StatsBase.jl/v0.23/means.html ) and encountering an error that weights function is missing.
Here is a complete example:
using Statistics
a = [1,2,3]
w = [3,4,5]
x = mean(a, weights(w))
and an error message
ERROR: UndefVarError: `weights` not defined
Stacktrace:
[1] top-level scope
What can be wrong?
This is an example of the StatsBase
package, not of Base.Statistics
:
julia> using StatsBase
julia> a = [1,2,3];
julia> w = [3,4,5];
julia> mean(a, weights(w))
2.1666666666666665
Also, just in case it isn't intentional, note that you're looking at the docs for a pretty old version of StatsBase. You can change to the current stable version's docs by clicking on the version number below the package name top left:
Screenshot_20230729_001526.png
Doesn't change anything for this particular function, just letting you know since search engines sometimes lead people to these older versions when they're looking for current docs.
Ok, this of course solved the issue! Thanks! And thanks for the tip on current documentation
pryumin has marked this topic as resolved.
Last updated: Dec 28 2024 at 04:38 UTC