vendredi 17 novembre 2017

Sampling with weight for 1 number

I want to sample from a big pool of numbers e.g. -2000:5000.
I would like thought to set the weight for a certain number to 80%.
Everything other possibility should be equal for every other number.

Doing this for a small sample is easy:
sample(-2:2, 10, replace = TRUE, prob=c(0.05, 0.05, 0.80, 0.05, 0.05))
this would output:

[1] 0 0 0 0 0 -1 0 0 0 0

How can I do this for a big range of numbers?




Aucun commentaire:

Enregistrer un commentaire