Skip to content

Instantly share code, notes, and snippets.

@privefl
Created September 17, 2017 10:26
Show Gist options
  • Save privefl/6a1ca203624cd5025136e6ee9be6d776 to your computer and use it in GitHub Desktop.
Save privefl/6a1ca203624cd5025136e6ee9be6d776 to your computer and use it in GitHub Desktop.
N <- 23e4
n <- 2e4
prb <- ifelse(sample(0:1, size = N, replace = TRUE) == 1, 1.0, 0.05)
smpl <- sampling::UPrandomsystematic(n / sum(prb) * prb)
table(prb[as.logical(smpl)])
table(prb[sample.int(N, size = n, replace = FALSE, prob = prb)])
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment