I have a vector of ~100k length, with values between 0 and 1 representing habitat suitability at geographic locations. While some of the values are very small, many of them are 0.9 etc, so the sum is much greater than one.
I would like to generate 1000 random samples of locations, each sample having length 6 (without replacement), with the probability that a location is chosen being weighted by the value of the vector at that location.
Dummy data below. Any ideas?
mylocs = letters[1:10]
myprobs = c(0.1,NA,0.01,0.2,0.6,NA,0.001,0.03,0.9,NA)
mydata = data.frame(mylocs,myprobs)
I’m a bit confused with your question, so here are two possible answers.
If you want you want to sample 1000 groups of six values, where groups can share values, then:
If groups shouldn’t share values, then just do: