-
Notifications
You must be signed in to change notification settings - Fork 194
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
ignoring elements with 0 weight #492
Comments
That kind of makes sense, but I wonder how it would affect performance. For example, the weighted mean/sum uses BLAS over dimensions, which I guess doesn't offer that flexibility -- and even in pure Julia code we wouldn't be able to use standard floating-point arithmetic unless I'm mistaken. |
I agree — we would need to branch on the weight I would be happy to sacrifice speed for this feature, but I understand that not everyone has the same preferences. Perhaps we could have an option selecting this behavior (zero weight elements don't participate in arithmetic), or having it enabled by default and disabling it on demand. If a PR for that could be considered, I would be happy to make one. Another interface option I can imagine for this is a wrapper on the weights, eg mean(x, SkipZeros(Weights(w))) and similarly for |
That code is going to be moved to Julia, see JuliaLang/julia#31395. I'm not sure an option would be acceptable, since it will have to be added directly to the Base Another solution (easier in the short term) is to wrap |
Thanks to #316,
quantile
now ignores elements with a0
weight. I wonder if the same would make sense for other functions, particularlymean
andstd
. CurrentlyMy motivation for this is working with data where I am calculating statistics of some
x ./ y
, weighted byy
. Wheny == 0
, the ratio is nonsensical, but at the same time weighting should make it irrelevant. Instead, now theNaN
propagates.This is nothing I cannot work around, it would just make my workflow more convenient.
The text was updated successfully, but these errors were encountered: