Skip to contents

A distribution defined by paired value/probability points, interpolated between. Mirrors the C# EmpiricalDistribution composite.

Usage

dist_empirical(
  x,
  p,
  p_transform = "NormalZ",
  p_descending = FALSE,
  extrapolation = "none"
)

Arguments

x

numeric vector of values.

p

numeric vector of associated probabilities, the same length as x.

p_transform

how p is interpolated between: "NormalZ" (the default) transforms through the standard-normal quantile; "None" interpolates p directly.

p_descending

whether p decreases as x increases (a survival-function encoding); FALSE (the default) is the ordinary ascending-CDF case.

extrapolation

sides on which to extend the boundary segments: "none" (default), "below", "above", or "both".

Value

a corehydro_dist of family "Empirical", accepted by every dist_*() verb.

Examples

d <- dist_empirical(x = c(1, 2, 3), p = c(0.1, 0.5, 0.9))
dist_quantile(d, 0.5)
#> [1] 2