Skip to contents

Access a distribution's probability density function (pdf).

Usage

eval_density(distribution, at, strict = TRUE)

enframe_density(
  ...,
  at,
  arg_name = ".arg",
  fn_prefix = "density",
  sep = "_",
  strict = TRUE
)

Arguments

distribution, ...

A distribution, or possibly multiple distributions in the case of ....

at

Vector of values to evaluate the cdf at. Must be named when using in enframe_.

strict

Only evaluate when the density exists? TRUE if so; if FALSE, evaluates the derivative of the cdf.

arg_name

For enframe_, name of the column containing the function arguments.

fn_prefix

For enframe_, name of the function to appear in the column(s).

sep

When enframe'ing more than one distribution, the character that will be separating the fn_name and the distribution name.

Value

The evaluated density in vector form (for eval_) and data frame or tibble form (for enframe_).

See also

Other distributional representations: eval_cdf(), eval_chf(), eval_hazard(), eval_odds(), eval_pmf(), eval_quantile(), eval_return(), eval_survival()

Examples

d <- dst_unif(0, 4)
eval_density(d, at = 0:4)
#> [1] 0.25 0.25 0.25 0.25 0.25
enframe_density(d, at = 0:4)
#> # A tibble: 5 × 2
#>    .arg density
#>   <int>   <dbl>
#> 1     0    0.25
#> 2     1    0.25
#> 3     2    0.25
#> 4     3    0.25
#> 5     4    0.25
eval_density(dst_pois(1), at = 0:4, strict = FALSE)
#> [1] 0 0 0 0 0