-
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
Allow numeric Vectors as weights #335
Comments
Quickly scanning the code it looks like we could probably just change the existing signatures. line 355countmap(x::AbstractArray{T}, wv::AbstractWeights{W}) where {T,W} to countmap(x::AbstractArray{T}, wv::AbstractVector{W}) where {T,W<:Real} line 320addcounts!(cm::Dict{T}, x::AbstractArray{T}, wv::AbstractWeights{W}) where {T,W} to addcounts!(cm::Dict{T}, x::AbstractArray{T}, wv::AbstractVector{W}) where {T,W<:Real} FWIW, I'm not sure it makes sense to call this method with anything other than |
Ok. I think keeping other signatures are fine. But the one that makes the most sense to me are just a straight weight vector of numerics |
Right, but doesn't the domain of the numerics matter (e.g., passing a vector of floating point values doesn't really make sense)? |
yeah we associate count a with something a discrete. But i think it's ok have negative and floating point weights. Some may want to use it. |
Actually, that's a complex issue. It can make sense to show the sum of analytic or probability weights, even if that's not necessarily an integer number. It's useful in particular to compute proportions. Stata's Given that treating weights as frequency weights is more natural in most cases (i.e. for frequency weights, probability weights and when the type isn't specified), I wonder whether it's worth having a special case for analytic weights. |
Hmmm, seems weird to support analytic weights and not probability weights, but I'd be fine with special casing them and assuming frequency weights otherwise. |
Came across this with As it stands it took a bit of time to look at the docs, understand what the different types of |
See also discussion at #443. |
When I first started using
countmap
I was confused about how to do a count with weights. I thoughtcountmap(x, wgt)
would do wherewgt
is a numeric vector. But actually we needcountmap(x, weights(wgt))
.When I looked into the documentation there are 3 types of weights: they are Analytical, Frequency and Probability; these seem to be useful. But before reading the source code I only thought of weights as a numeric weight for each value and I suspect a lot of people would think like that too.
So do you think it's ok to add this signature?
countmap(Vector{T}, Vectr{S}) where {T, S<:Number}
The text was updated successfully, but these errors were encountered: