| rbiased | R Documentation |
This function generates a biased sample of size n using \insertCiteneumann1951;textualWData acceptance-rejection method. The generated sample is biased according to the provided bias function w, with respect to the unbiased density function fx.
rbiased(
n,
w = function(y) {
ifelse(y >= 0, y, NA)
},
fx,
lim = 0.01,
plot = TRUE,
stop = TRUE,
shape1,
shape2,
location,
scale,
df,
ncp,
rate,
df1,
df2,
shape,
meanlog,
sdlog,
min,
max,
mgshape,
mgscale,
mgweight,
pro,
mean,
sd
)
n |
Sample size. |
w |
A function representing the bias function applied to the data points. It must be evaluable and positive in each point of the sample |
fx |
Unbiased density function. Values allowed are
Beta ( |
lim |
Lower and upper limits for the range where the bias is significant and, hence, where |
plot |
Logical value indicating whether to generate a plot of the biased sample. Default is |
stop |
Logical value indicating whether to stop when bias function can not be evaluated in a generated value. Default is |
shape1, shape2 |
Additional arguments to be passed to the unbiased density function |
df, ncp |
Additional arguments to be passed to the unbiased density function |
df1, df2 |
Additional arguments to be passed to the unbiased density function |
shape, rate, scale, location |
Additional arguments to be passed to the unbiased density function |
min, max |
Additional arguments to be passed to the unbiased density function |
mgshape, mgscale, mgweight |
Shape, scale, and mixing weights for the gamma components when |
mean, sd, pro, meanlog, sdlog |
Additional arguments to be passed to the unbiased density function |
This function implements \insertCiteneumann1951;textualWData acceptance-rejection method to generate a biased sample given an unbiased density function fx and a bias function w.
A numeric vector containing a biased sample from density fx and bias function w.
# Generate a length-biased sample of size 100 from an exponential distribution
rbiased(n = 100, fx = "exp", rate = 2, plot = FALSE)
# Generate a length-biased sample from a gamma distribution
rbiased(n = 100, fx = "gamma", rate = 1.5^2, shape = 1.5)
# Generate a biased sample from a gaussian distribution
custom_bias <- function(y) {
y^2
}
rbiased(n = 100, w = custom_bias, fx = "norm", mean = 3, sd = 10, plot = TRUE)
# Generate a biased sample from a mixture of gaussian distributions
custom_bias <- function(y) {
sqrt(abs(y)) + 5
}
rbiased(
n = 100, w = custom_bias, fx = "mixnorm", pro = rep(1 / 3, 3), mean = c(0.25, 0.5, 0.75),
sd = rep(0.075, 3)
)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.