sampleQ {flimo}R Documentation

Sample function with fixed quantiles

Description

Replace the sample function in the context of fixed quantiles. Warning : first argument has less features.

Usage

sampleQ(x, size, quantiles, replace = FALSE, prob = NULL)

Arguments

x

a vector of one or more elements from which to choose.

size

a non-negative integer giving the number of items to choose.

quantiles

1D array containing values drawn in U(0,1). Length has to be equal to size.

replace

should sampling be with replacement ?

prob

a vector of probability weights for obtaining the elements of the vector being sampled.

Value

a vector of length size with elements drawn from x.

Examples


set.seed(1)
quantiles <- runif(40)
sampleQ(1:10, 10, quantiles[1:10])
sampleQ(1:10, 10, quantiles[11:20])
sampleQ(11:20, 10, quantiles[1:10])
sampleQ(1:10, 20, quantiles[21:40], replace = TRUE)


[Package flimo version 0.1.5 Index]