| make.c.dist | R Documentation |
Defines a probability distribution object for use with
compare.samplers with log-density implemented in C.
make.c.dist(ndim, name, c.log.density, c.context = NULL,
name.expression = NULL, mean = NULL, cov = NULL)
ndim |
The size of the distribution's state space. |
name |
A human-readable name for the distribution. |
c.log.density |
A C function returning the log-density and gradient of the target distribution. |
c.context |
An opaque object passed to |
name.expression |
A name for the distribution in
|
mean |
A vector specifying the true mean of the distribution. |
cov |
A matrix specifying the true covariance of the distribution. |
See make.dist for discussion of ndim,
name, name.expression, mean, and cov.
c.log.density is a string containing the symbol name of a
C function that computes the log density and log density gradient
of the target distribution. It has the type log_density_t,
defined in SamplerCompare.h as:
typedef double log_density_t(dist_t *ds, double *x,
int compute_grad, double *grad);
typedef struct {
log_density_t *log_dens;
SEXP context;
int ndim;
} dist_t;
The ds structure defines the distribution, where the
log_dens element is a pointer to the function named by
c.log.density, the context element is a SEXP
containing the c.context parameter, and ndim is the
ndim parameter to make.c.dist.
The x parameter is an ndim-long array of doubles
containing the location at which to evaluate the log-density,
which the log_density_t should return.
If compute_grad is nonzero, the function should compute
the gradient of the log density and store it in the double array
pointed to by grad. If for some reason it cannot do this,
it should call the R-internal error function to report an
error to the user. If the implementor does not plan to sample
from the distribution with a method that computes gradients, this
can reduce implementation effort.
The details of this interface are described in greater detail in “R/C Glue in SamplerCompare”.
A scdist object.
compare.samplers,
make.dist,
“R/C Glue in SamplerCompare” (vignette)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.