Say I have a probability mass p = [p_1, p_2, ..., p_n] over the numbers 1 to n, such that sum(p)=1.
I want to sample a binary vector x of length n, such that sum(x) = N (N is known) and each component 1 to n is sampled with the probability mass p.
What's the most efficient way of doing this? Many thanks.
Aucun commentaire:
Enregistrer un commentaire