Learn R Programming

SamplingBigData (version 1.0.0)

split_sample: Split Sample

Description

This is a fast implementation of the pivotal method.

Usage

split_sample(
     prob,
     delta  = exp(-16)
     )

Arguments

prob

An array of length N such that the sum of prob is equal to the sample size.

delta

A small real value that is used for tolerance in determining if the value is included or excluded from the sample.

Value

An array of indexes from prob. Indexes with this list are sampled.

References

Deville, J.-C. and Till<U+00E9>, Y. (1998). Unequal probability sampling without replacement through a splitting method. Biometrika 85, 89-101.

Examples

Run this code
# NOT RUN {

N <- 1000
n <- 100
runif(N)

set.seed(100)
Cprog <- proc.time()
sampled <- split_sample( rep(n/N,N))
print(proc.time() - Cprog) 

# }

Run the code above in your browser using DataLab