I have a problem with the sample function. I have an error that incorrect number of probabilities. Can I use probability in another way? I don't know that this function works on intervals.
OL_x = c(15.0:47.0,0.0:15.0,47:80,80:105)
x = sample(OL_x,1000,replace = TRUE,prob = c(0.60,0.22,0.13,0.05) )+ runif(1000,0,1)
You need to have a probability associated with each value, i don't know a way to assign a probability to an interval, so doing it "by hand" could be like:
probs = c(rep(0.60, 48-15), rep(0.22,16-0), rep(0.13, 81-47), rep(0.05, 106-80))
x = sample(OL_x, 1000, replace = TRUE, prob = probs) + runif(1000,0,1)
This is not much efficient because you need to calculate the size of each interval by hand, there are probably better ways of doing this.