random.function: Random Draw Generator

Description Usage Arguments Details Value Note Author(s) See Also Examples

Description

This function generates random draws of a continuous random variable given either its density or its cumulative distribution function.

Usage

1
random.function(n = 1, f, lower = -Inf, upper = Inf, kind = "density")

Arguments

n

number of draws, default 1.

f

either a density (default) or cumulative distribution function of the random variable.

lower

lower limit of the support of the random variable, default -Inf.

upper

upper limit of the support of the random variable, default Inf.

kind

character string with the function used to identify the distribution, either "density" (default) or "cumulative", as alternative.

Details

random.function uses the method of the inverse of the cdf to generate random draws from f.

Value

A vector of length n with n draws from a random variable with density (or cumulative distribution) function given by f.

Note

random.function is called by dgeometric.test when the corresponding r- function (random generator of f) is not available in the environment. random.function generates random samples from the null hypothesis density function specified in dgeometric.test.

Author(s)

Jose M. Pavia

See Also

dgeometric.test, integrate, inverse and support.facto.

Examples

1
2
f0 <- function(x) ifelse(x>=0 & x<=1, 2-2*x, 0)
random.function(10, f0, lower=0, upper=1, kind="density")

Example output

Loading required package: KernSmooth
KernSmooth 2.23 loaded
Copyright M. P. Wand 1997-2009
 [1] 0.080654738 0.324932922 0.006656094 0.001281151 0.048393429 0.624668120
 [7] 0.816124253 0.075799431 0.332043682 0.160057994

GoFKernel documentation built on May 2, 2019, 11:41 a.m.