Using sample.int in R I am drawing random samples for two populations (in the example, 10 individuals). If there is a small change in the probabilities, like a change from c(0.5,0.5) to c(0.51, 0.49) I would like the the sampling to be more or less maintained, i.e. most individuals would be assigned the same draw (e.g. if we had a population of 100, maybe 1 individual would change their assignment). How might this be done?
set.seed(123)
probs.1<-c(0.51,0.49)
sample.int(n=2,
replace = TRUE,
size=10,
prob=probs.1)
#[1] 1 1 2 2 2 2 1 1 2 1
set.seed(123)
probs.2<-c(0.5,0.5)
sample.int(n=2,
replace = TRUE,
size=10,
prob=probs.2)
#[1] 2 2 1 1 1 1 2 2 1 2
Aucun commentaire:
Enregistrer un commentaire