Function to sample Empirical Distributions without replacement, as opposed to the rand method which samples with replacement.

simulateEmpiricalDistribution(EmpiricalDist, n, seed = NULL)

Arguments

EmpiricalDist

Empirical Distribution

n

Number of samples to generate. See Details.

seed

Numeric passed to set.seed. See Details.

Value

A vector of length n with elements drawn without replacement from the given Empirical distribution.

Details

This function can only be used to sample from the Empirical distribution without replacement, and will return an error for other distributions.

The seed param ensures that the same samples can be reproduced and is more convenient than using the set.seed() function each time before use. If set.seed is NULL then the seed is left unchanged (NULL is not passed to the set.seed function).

If n is of length greater than one, then n is taken to be the length of n. If n is greater than the number of observations in the Empirical distribution, then n is taken to be the number of observations in the distribution.