Become an expert in R — Interactive courses, Cheat Sheets, certificates and more!
Get Started for Free

simulateEmpiricalDistribution

Sample Empirical Distribution Without Replacement


Description

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

Usage

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.

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.

Value

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


distr6

The Complete R6 Probability Distributions Interface

v1.5.2
MIT + file LICENSE
Authors
Raphael Sonabend [aut, cre] (<https://orcid.org/0000-0001-9225-4654>), Franz Kiraly [aut], Peter Ruckdeschel [ctb] (Author of distr), Matthias Kohl [ctb] (Author of distr), Nurul Ain Toha [ctb], Shen Chen [ctb], Jordan Deenichin [ctb], Chengyang Gao [ctb], Chloe Zhaoyuan Gu [ctb], Yunjie He [ctb], Xiaowen Huang [ctb], Shuhan Liu [ctb], Runlong Yu [ctb], Chijing Zeng [ctb], Qian Zhou [ctb]
Initial release

We don't support your browser anymore

Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.