rejection | R Documentation |
Generate random variate satisfying the constraint function by the Rejection algorithm.
rejection(constr, nvars, LB=0, UB=1, ..., echo=FALSE,
method=c("unif","norm", "normcap"), control=list())
constr |
Constraint function |
nvars |
Number of variables |
LB |
Lower bound |
UB |
Upper bound |
... |
further arguments to pass to |
echo |
a logical to plot traces. |
method |
the distribution to draw random variates, either |
control |
a named list containing the mean and the standard deviation
of the normal distribution used if |
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).
A vector x
which verifies the constraints constr(x) <= 0
.
Christophe Dutang
See also GNE
.
f <- function(x) x[1]^2 + x[2]^2 - 1
rejection(f, 2, -3, 3, method="unif")
rejection(f, 2, -3, 3, method="norm")
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.