R/UPsystematic.R

"UPsystematic"<-function(pik,eps=1e-6) 
{
if(any(is.na(pik))) stop("there are missing values in the pik vector")
list=pik > eps & pik < 1-eps
pik1 = pik[list]
N = length(pik1)
a = (c(0, cumsum(pik1)) - runif(1, 0, 1))%%1
s1 = as.integer(a[1:N] > a[2:(N + 1)])
s = pik
s[list] = s1
s
}

Try the sampling package in your browser

Any scripts or data that you put into this service are public.

sampling documentation built on Nov. 2, 2023, 6:26 p.m.