Access a distribution's probability mass function (pmf).

eval_pmf(distribution, at, strict = TRUE)

enframe_pmf(
...,
at,
arg_name = ".arg",
fn_prefix = "pmf",
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 pmf exists? TRUE if so; if FALSE, simply evaluates the probability of the specified outcomes.

...

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

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 probabilities in vector form (for eval_) and data frame or tibble form (for enframe_).

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

Examples

d <- dst_empirical(1:10)
eval_pmf(d, at = c(1, 2, 2.5))
#> [1] 0.1 0.1 0.0
enframe_pmf(d, at = 0:4)
#> # A tibble: 5 × 2
#>    .arg   pmf
#>   <int> <dbl>
#> 1     0   0
#> 2     1   0.1
#> 3     2   0.1
#> 4     3   0.1
#> 5     4   0.1
eval_pmf(dst_norm(0, 1), at = -3:3, strict = FALSE)
#> [1] 0 0 0 0 0 0 0