# Sampling from a population with individual probabilities?

I would like to draw sample from a population but I want my sampling probability to be different for each individual. For example, suppose I will take a sample of two from a population of three which is made up of c("A","B","C"). I want to define sampling probabilities for each of these differently(say 0.6, 0.2, 0.2, respectively). How can I define such a sampling structure in R? I want my sampling to be without replacement.

If you want an off-the-shelf solution, sample method in R is suitable for you. The first argument, x is your array, the second argument n is number of samples to choose. replace argument is FALSE in your case, which is also the default behavior (for the version (i.e. 3.5.3) in the link). And, you'll give your probability vector to the prob argument.
Edit: Stick with the R implementation, described above. For the theory behind, I've found this slightly complicated article. There are various others in internet, even for the simple special case $$n=2$$.
Generate a random number in $$[0,1]$$, and then map it to the cumulative distribution of your elements (e.g. elements in $$[0,0.6)$$ maps to $$A$$, $$[0.6,0.8)$$ maps to $$B$$, and so on ...). After picking up your element, remove it from corresponding probability and element arrays, and then normalize your remaining probability vector such that it sums up to $$1$$; then sample one more element and so on.
• The second paragraph gives an incorrect procedure. Sampling one element with unequal probabilities is easy. Sampling more than one without replacement is incredibly difficult to do right. You have to rescale the probabilities in weird ways to make sure that your ultimate unit selection probability matches your target. library(sample) does it right, so there is no reason to try and invent a circular propulsion device. Apr 1 '19 at 22:26