Skip to contents

Mirrors the Numerics LinearFunction (Y = alpha + beta*X + epsilon) and PowerFunction (Y = alpha * (X - xi)^beta * epsilon), both over optional normally distributed noise (epsilon ~ Normal(0, sigma)) 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.

Usage

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

Arguments

type

"linear" or "power", matched case-insensitively.

parameters

a numeric vector: c(alpha, beta, sigma) for "linear"; c(alpha, beta, xi, sigma) for "power". sigma is still required (e.g. 0) when confidence_level is NULL – it only enters the calculation on the non-deterministic path.

x

a numeric vector: the values to evaluate the function at, or (when inverse = TRUE) the values to evaluate the inverse function at.

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.

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