I have a vector that allows for duplicates, I want to randomly chose an element with the probability that represents how many times an element was repeated.
For example - for the vector below, 6 should have the highest probability of being chosen. I thought about using rand()
, but I am not quiet sure how to incorporate the probability.
vector A = [ 0, 0, 2, 2, 4, 5, 1, 6, 6, 6]
thanks