Skip to contents

Mirrors the Numerics linear, power, segmented power, composite, and ensemble function surfaces. A character type keeps the compact linear and power interface. A list type is a shared function spec and parameters is then the evaluation vector. Composite specs contain nested functions and optional weights and mode. Ensemble specs contain a template, parameter_sets, and either sample_index or sample_percentile.

Usage

univariate_function(
  type,
  parameters,
  x = NULL,
  inverse = FALSE,
  is_inverse = FALSE,
  confidence_level = NULL
)

Arguments

type

"linear", "power", or "segmented_power", matched case-insensitively, or a shared function spec list.

parameters

a numeric parameter vector for a character type. For a spec list, the values at which to evaluate the function.

x

optional numeric values at which to evaluate a spec list. For a character type, the values at which to evaluate the function or inverse function.

inverse

if TRUE, evaluates the inverse function (InverseFunction()) instead of the forward function (Function()).

is_inverse

"power"-only: PowerFunction's own IsInverse property. An error for type = "linear".

confidence_level

if given, evaluates the non-deterministic path at this quantile level; if NULL (default), evaluates deterministically.

Value

a numeric vector the same length as x.

Details

Linear and power functions support optional normally distributed noise via confidence_level. is_inverse (PowerFunction's own IsInverse switch) selects which of the forward power law or its algebraic inverse Function()/inverse = TRUE evaluates – an independent axis from inverse itself, which picks Function() vs. InverseFunction() on whichever of the two is_inverse selects.

Examples

univariate_function("linear", c(0, 1, 0), c(1, 2, 3))
#> [1] 1 2 3
univariate_function("power", c(5, 2, 0, 3), 6)
#> [1] 180
univariate_function("power", c(5, 2, 0, 3), 6, confidence_level = 0.75)
#> [1] 1361.614