N <- 100
n <- 10
p <- 10
pik <- rep(n/N,N)
Xaux <- array(rnorm(N*p,3,1),c(N,p))
Xspread <- cbind(runif(N),runif(N))
Xaux <- cbind(pik,Xaux)
s <- balseq(pik,Xaux)
colSums(Xaux[s,]/as.vector(pik[s]))
colSums(Xaux)
s <- balseq(pik,Xaux,Xspread)
colSums(Xaux[s,]/as.vector(pik[s]))
colSums(Xaux)
Run the code above in your browser using DataLab