What's the probability of finding element A
at index i
in array R
after shuffling it with a random sampling algorithm? Is there a general formula for that?
Example: Given array ['a', 'b', 'c']
and weights [3, 2, 1]
:
p[a at 0] = 50%
p[a at 1] = 35%
p[a at 2] = 15%
I found this by making a simulation with thousands of shuffles.
The weighted sampling/shuffle algorithm: http://utopia.duth.gr/~pefraimi/research/data/2007EncOfAlg.pdf
Aucun commentaire:
Enregistrer un commentaire