Skip to contents

Summarize a distribution with a set of quantiles

Usage

extrapolate_quantiles(x, probs, replace_na = TRUE, ...)

Arguments

x

a distribution vector

probs

a vector of probabilities at which to calculate quantiles

replace_na

logical. If x contains NA's, these are imputed if possible (if TRUE) or retained (if FALSE). This only effects elements of class dist_quantiles.

...

additional arguments passed on to the quantile method

Value

a distribution vector containing dist_quantiles. Any elements of x which were originally dist_quantiles will now have a superset of the original quantile_values (the union of those and probs).

Examples

library(distributional)
dstn <- dist_normal(c(10, 2), c(5, 10))
extrapolate_quantiles(dstn, probs = c(.25, 0.5, .75))
#> <distribution[2]>
#> [1] quantiles(10)[3] quantiles(2)[3] 

dstn <- dist_quantiles(list(1:4, 8:11), list(c(.2, .4, .6, .8)))
# because this distribution is already quantiles, any extra quantiles are
# appended
extrapolate_quantiles(dstn, probs = c(.25, 0.5, .75))
#> <distribution[2]>
#> [1] quantiles(2.5)[7] quantiles(9.5)[7]

dstn <- c(
  dist_normal(c(10, 2), c(5, 10)),
  dist_quantiles(list(1:4, 8:11), list(c(.2, .4, .6, .8)))
)
extrapolate_quantiles(dstn, probs = c(.25, 0.5, .75))
#> <distribution[4]>
#> [1] quantiles(10)[3]  quantiles(2)[3]   quantiles(2.5)[7] quantiles(9.5)[7]