I have the vector d<-1:100
I want to sample k=3 times from this vector without replacement. I would like to make elements that are at a distance length(d)/k
from the first sampled element to have a higher probability of getting sampled. I am not yet sure how much higher. I know that sample
has a prob=
argument, however i can't seem to find a way so that the prob=
vectors gets to be recalculated from the location of the initial sample.
Any ideas?
Example:
d<-1:100
. Lets say the first trial samples d[30]=30
. Then the elements of ddd
that are near 0, 60 and 90 should have a higher probability of sampling. So after the initial sample the the distribution of the sampling probabilities of the rest of the elements of ddd
is as in the image:
I think:
samp <- sample(1:100,1)
prob <- rep(1,100)
prob[samp]=0
MORE EDIT: I'm an idiot today. Now this will make the probability shape you asked for.
peke<-c(2,5,7,10,7,5,2) #your 'triangle' probability
for (jj = c(0,2,3){
prob[(1:7)*(1+samp*(jj)] <- peke
}
newsamp <-sample(1:100,1,prob)
You may want to add a slight offset if that doesn't place the probability peaks where you wanted them.