n <- 20
w <- runif(n)
#can use M != to length(wts)
low_var_sample(wts=w, M=15)
lv <- low_var_sample(wts=w, M=n)
#usual resampling with weights
a <- sample(x=1:n, size=n, prob=w, replace=TRUE)
#the first should be more in proportion to weights
table(lv)/n
table(a)/n
#proportions
w/sum(w)
Run the code above in your browser using DataLab