I have a population p of indices and corresponding weights in vector w. I want to get k samples from this population without repla
p
w
k
I think you should keep using the for, but I suggest to reduce the corresponding weight by one.
w(p == J(i)) = w(p == J(i)) -1;