StatsBase.jl
StatsBase.jl copied to clipboard
Specialized vcat and similar for AbstractWeights?
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.
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.