Skip to contents

Mirrors the C# TabularFunction: builds an uncertain paired curve from x and distributions, samples it once (the mean curve, or confidence_level if given), and evaluates Function()/InverseFunction() at at. Unlike curve_interpolate() and friends, the underlying curve's shape contract is not configurable here – TabularFunction is always built strict, ascending on both axes, matching every use in the ported C# test suite.

Usage

tabular_function(
  x,
  distributions,
  at,
  inverse = FALSE,
  x_transform = "none",
  y_transform = "none",
  confidence_level = NULL,
  allow_negative_y_values = FALSE
)

Arguments

x

numeric vector, the curve's x positions, at least one element.

distributions

a distribution() object, or a list of them the same length as x – one distribution per x position. A single distribution is recycled across every x.

at

numeric vector of points to evaluate at (or, when inverse = TRUE, points to evaluate the inverse function at).

inverse

if TRUE, evaluates InverseFunction() instead of Function().

x_transform, y_transform

one of "none" (default), "logarithmic" (also accepted as "log"), or "normal_z".

confidence_level

quantile in [0, 1] to sample the curve at; NULL (default) samples the mean.

allow_negative_y_values

allow a negative or NaN result to pass through unmodified, rather than clamping it to 0. Default FALSE (clamp), matching every use in the ported C# test suite – the C# class default is TRUE.

Value

a numeric vector, the same length as at.

Examples

x <- c(50, 100, 150, 200, 250)
d <- lapply(c(100, 200, 300, 400, 500), function(v) distribution("Deterministic", v))
tabular_function(x, d, at = 50, x_transform = "logarithmic")
#> [1] 100