util-rejectalgo: Rejection method for random generation.

rejectionR Documentation

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())

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".

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).

Value

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

Author(s)

Christophe Dutang

See Also

See also GNE.

Examples


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

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

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


GNE documentation built on March 31, 2023, 9:25 p.m.