I can sample from a 1-D array just fine. E.g.
julia> a = [1; 2; 3]
3-element Array{Int64,1}:
1
2
3
julia> sample(a, myweights, 5)
5-element Array{Int64,1}:
1
2
1
3
3
I can also take weighted samples:
julia> myweights = weights([0.8, 0.1, 0.1])
StatsBase.WeightVec{Float64,Array{Float64,1}}([0.8,0.1,0.1],1.0)
julia> sample(a, myweights, 5)
5-element Array{Int64,1}:
2
1
1
1
1
I'd like to do the same thing for a 2D array, but sampling by row and not by element. E.g. if I have the array
julia> b = [1 1 1; 2 2 2; 3 3 3]
3×3 Array{Int64,2}:
1 1 1
2 2 2
3 3 3
I'd like to be able to take unweighted and weighted samples that give me outputs like
1 1 1
2 2 2
1 1 1
1 1 1
3 3 3
How can I do this?