-
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
Weighted Arrays? #776
Comments
There's been some discussion about something similar at JuliaLang/julia#33310 (comment) (and following comments) and https://github.com/JuliaLang/Statistics.jl/issues/88. It could be an interesting alternative to passing weights as a separate argument. But I find the syntax a bit weird with functions that take several arguments, like Regarding performance, it would probably not be faster:
julia> Base.summarysize(fill((Int8(1), 1.0), 10_000))
160040
julia> Base.summarysize(fill(Int8(1), 10_000)) + Base.summarysize(fill(1.0, 10_000))
90080
|
It's a semantic issue rather than a syntax issue. Think about If one could define a meaningful operation then the semantic problem would be gone entirely. E.g.
Here the definition of But I'm not a fan of hiding things by putting everything into classes. Long live Vector functions! Coming from python, I find having to define classes for weights and for weighted arrays is not very transparent, because it is a judgement about the "quality" of the objects instead of its "function", which I find is problematic in general, in coding (lack of transparency) like in society. I would much prefer having separate functions such as wmedian (possibly with type 1, ... , 7?? as additional parameter) that take Vector typed values and weights as separate arguments, like it is now, but also without the Weight classes really (or at least also accept Vector and internally convert to Weight?). In any case the distinction between Frequency and Probability Weights already goes too far IMO. |
I've been considering this for a while. Would it make sense to define a new struct, a
weighted_array
, which contains both an array and a set of weights? The primary advantages are as follows:(element, weight)
tuples. Weights and array elements are almost always accessed together, so this allows for faster access.weighted_array
s to be passed as a single argument in place of an array.(The old interface can also be kept.)
The text was updated successfully, but these errors were encountered: