I’m running into an issue that I’m hoping someone can help me understand. I have a 1308 x 22 DataFrame that I’m trying to sample from with StatsBase. All is well and fine as long as n <= 31
.
The code looks like this:
julia> df
1308×22 DataFrame. Omitted printing of 8 columns
...
julia> wv = FrequencyWeights(df.PWORWGT)
1308-element FrequencyWeights{Int64,Int64,Array{Int64,1}}:
...
julia> sample(axes(df,1), wv, 31)
31-element Array{Int64,1}:
...
# If I change 31 to 32, I get this:
julia> sample(axes(df,1), wv, 32)
ERROR: MethodError: no method matching make_alias_table!(::Array{Int64,1}, ::Int64, ::Array{Float64,1}, ::Array{Int64,1})
Closest candidates are:
make_alias_table!(::AbstractArray{Float64,1}, ::Float64, ::AbstractArray{Float64,1}, ::AbstractArray{Int64,1}) at C:\Users\mthel\.julia\packages\StatsBase\DyWPR\src\sampling.jl:471
Stacktrace:
[1] alias_sample!(::Random._GLOBAL_RNG, ::Base.OneTo{Int64}, ::FrequencyWeights{Int64,Int64,Array{Int64,1}}, ::Array{Int64,1}) at C:\Users\mthel\.julia\packages\StatsBase\DyWPR\src\sampling.jl:533
[2] #sample!#153(::Bool, ::Bool, ::typeof(sample!), ::Random._GLOBAL_RNG, ::Base.OneTo{Int64}, ::FrequencyWeights{Int64,Int64,Array{Int64,1}}, ::Array{Int64,1}) at C:\Users\mthel\.julia\packages\StatsBase\DyWPR\src\sampling.jl:768
[3] #sample#154 at .\none:0 [inlined]
[4] #sample at .\none:0 [inlined]
[5] #sample#155 at C:\Users\mthel\.julia\packages\StatsBase\DyWPR\src\sampling.jl:789 [inlined]
[6] sample(::Base.OneTo{Int64}, ::FrequencyWeights{Int64,Int64,Array{Int64,1}}, ::Int64) at C:\Users\mthel\.julia\packages\StatsBase\DyWPR\src\sampling.jl:789
[7] top-level scope at REPL[29]:1
Is this a bug that I should report, or am I missing something? If I remove the weight vector, it works fine, regardless of what number I pick for n
.