Description Usage Arguments Details Value Examples
Bootstrap resampling with replacement from a distribution of a random variable stored in an rvtable.
1 2 | sample_rvtable(x, resample = FALSE, n = 10000, interp = TRUE,
n.interp = 1e+05, decimals = NULL, density.args)
|
x |
an |
resample |
if |
n |
bootstrap sample size. |
interp |
linearly interpolate between observed values of Val before sampling if Val is continuous. Ignored for discrete random variables. |
n.interp |
length of sequence of interpolated sampling points if. Ignored for discrete random variables or |
decimals |
number of decimal places for rounding samples. Ignored for discrete random variables. |
density.args |
optional arguments passed to |
Resample an rvtable yielding a new rvtable.
This is used to convert from a distribution-based rvtable, which has Val and Prob columns representing a distribution to one with only a Val column representing samples from a distribution.
This is often used preceding plotting data in an rvtable so that samples may be passed to plot code rather than a representation of a distribution using values and associated probabilities.
This function can also take a sample-based rvtable, in which case it will resample it if resample=TRUE
.
If is sample-based rvtable is passed and the random variable is continuous, the generation of a new continuous density prior to resampling can be controlled via density.args
.
All rvtable objects are either distribution-based or sample-based.
an rvtable
object where the Val column represents samples and the Prob column is dropped.
1 2 3 4 5 | x <- rvtable(rnorm(1000))
sample_rvtable(x, n=10)
x <- rvtable(sample(1:100, 50), discrete=TRUE)
y <- sample_rvtable(x, n=10)
sample_rvtable(y, n=8, resample=TRUE)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.