Learn R Programming

GNE (version 0.99-6)

rejection: Rejection method for random generation.

Description

Generate random variate satisfying the constraint function by the Rejection algorithm.

Usage

rejection(constr, nvars, LB=0, UB=1, ..., echo=FALSE, 
	method=c("unif","norm", "normcap"), control=list())

Value

A vector x which verifies the constraints constr(x) <= 0.

Arguments

constr

Constraint function

nvars

Number of variables

LB

Lower bound

UB

Upper bound

...

further arguments to pass to constr function.

echo

a logical to plot traces.

method

the distribution to draw random variates, either "unif", "norm", "normcap".

control

a named list containing the mean and the standard deviation of the normal distribution used if method!="unif".

Author

Christophe Dutang

Details

Draw random variates x until all the components of constr(x) are negative. The distribution to draw random variates can be the uniform distribution on the hypercube defined by LB and UB, the normal distribution centered in (LB + UB)/2 and standard deviation (UB - LB) / (4*1.9600) and the capped normal distribution (intended for debug use).

See Also

See also GNE.

Examples

Run this code

f <- function(x) x[1]^2 + x[2]^2 - 1

rejection(f, 2, -3, 3, method="unif")

rejection(f, 2, -3, 3, method="norm")

Run the code above in your browser using DataLab