pdf {distributions3} | R Documentation |
Evaluate the probability density of a probability distribution
Description
Generic function for computing probability density function (PDF) contributions based on a distribution object and observed data.
Usage
pdf(d, x, drop = TRUE, ...)
log_pdf(d, x, ...)
pmf(d, x, ...)
Arguments
d |
An object. The package provides methods for distribution
objects such as those from |
x |
A vector of elements whose probabilities you would like to
determine given the distribution |
drop |
logical. Should the result be simplified to a vector if possible? |
... |
Arguments passed to methods. Unevaluated arguments will generate a warning to catch mispellings or other possible errors. |
Details
The generic function pdf()
computes the probability density,
both for continuous and discrete distributions. pmf()
(for the
probability mass function) is an alias that just calls pdf()
internally.
For computing log-density contributions (e.g., to a log-likelihood)
either pdf(..., log = TRUE)
can be used or the generic function
log_pdf()
.
Value
Probabilities corresponding to the vector x
.
Examples
## distribution object
X <- Normal()
## probability density
pdf(X, c(1, 2, 3, 4, 5))
pmf(X, c(1, 2, 3, 4, 5))
## log-density
pdf(X, c(1, 2, 3, 4, 5), log = TRUE)
log_pdf(X, c(1, 2, 3, 4, 5))