Skip to contents

Set the bounds that constrain a distribution when it is discretised: max truncates the support at that value, while cdf_max trims the tail by keeping the distribution only up to its cdf_max quantile. Either bound drops the mass beyond it and renormalises the remaining PMF to sum to one.

Usage

bound_dist(x, max = Inf, cdf_max = 1, cdf_cutoff = deprecated())

Arguments

x

A <dist_spec>.

max

Numeric, maximum value of the distribution. The distribution will be truncated at this value. Default: Inf, i.e. no maximum.

cdf_max

Numeric in (0, 1]; the cumulative probability up to which the distribution is kept, i.e. it is truncated at the cdf_max quantile. For example cdf_max = 0.999 keeps the distribution up to its 99.9th percentile. Default: 1, i.e. keep the full distribution. A value below 0.5 is rejected, as it is almost certainly the tail probability to drop rather than the CDF level to keep (use 1 - x instead).

cdf_cutoff

[Deprecated] Renamed to cdf_max. Supplying it warns and the value is interpreted as cdf_max, i.e. the CDF level to keep (the distspec 0.1.0 convention). A value in the historical EpiNow2 convention (the tail probability to drop) is caught by the guard against values below 0.5; pass cdf_max = 1 - cdf_cutoff instead.

Value

a <dist_spec> with relevant attributes set that define its bounds

See also

discretise(), which applies these bounds when producing a PMF.

Examples

# Truncate a gamma distribution at 20
bound_dist(Gamma(mean = 5, sd = 1), max = 20)
#> - gamma distribution (max: 19):
#>   shape:
#>     25
#>   rate:
#>     5
# Keep it up to its 99.9th percentile
bound_dist(Gamma(mean = 5, sd = 1), cdf_max = 0.999)
#> - gamma distribution (cdf_max: 0.999):
#>   shape:
#>     25
#>   rate:
#>     5