StatsBase.jl icon indicating copy to clipboard operation
StatsBase.jl copied to clipboard

Specialized vcat and similar for AbstractWeights?

Open oschulz opened this issue 3 years ago • 1 comments

When combining vectors/tables of samples, we currently lose weight-type information:

julia> vcat(FrequencyWeights(rand(3)), FrequencyWeights(rand(5)))
8-element Vector{Float64}:

julia> vcat(uweights(3), uweights(5))
10-element Vector{Int64}:

As combining/appending samples is a common operations, I think it would make sense to specialize things like vcat to preserve weight type.

oschulz avatar Apr 06 '22 12:04 oschulz

Seems reasonable to add definitions whenever it makes sense, and fall back to the generic definition otherwise. This came up also in https://github.com/TuringLang/MCMCChains.jl/pull/354.

devmotion avatar Apr 06 '22 12:04 devmotion