| ud | R Documentation |
Evaluates the probability density function (PDF) or probability mass function (PMF) for a "unuran" object for a continuous and discrete distribution, respectively.
ud(obj, x, islog = FALSE)
obj |
one of
|
x |
vector of x values. (numeric) |
islog |
if |
The routine evaluates the probability density function of a
distribution stored in a UNU.RAN distribution object or UNU.RAN
generator object. If islog is TRUE, then the logarithm
of the density is returned.
If the PDF (or its respective logarithm) is not available in the
object, then NA is returned and a warning is thrown.
Note: when the log-density is not given explicitly (by setting
islog=TRUE in the corresponding routing like
unuran.cont.new or in an Runuran built-in
distribution), then NA is returned even if the density is
given.
Important:
Routine ud just evaluates the density function that is stored
in obj. It ignores the boundaries of the domain of the
distribution, i.e., it does not return 0 outside the domain
unless the implementation of the PDF handles this case correctly.
This behavior is in particular important when Runuran
built-in distributions are truncated by explicitly setting the domain
boundaries.
The generator object must not be packed (see
unuran.packed).
Josef Leydold and Wolfgang H\"ormann unuran@statmath.wu.ac.at.
W. H\"ormann, J. Leydold, and G. Derflinger (2004): Automatic Nonuniform Random Variate Generation. Springer-Verlag, Berlin Heidelberg.
unuran.cont,
unuran.discr,
unuran.
## Create an UNU.RAN distribution object (for standard Gaussian)
## and evaluate density for some points
distr <- udnorm()
ud(distr, 1.5)
ud(distr, -3:3)
## Create an UNU.RAN generator object (for standard Gaussian)
## and evaluate density of underyling distribution
gen <- tdrd.new(udnorm())
ud(gen, 1.5)
ud(gen, -3:3)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.