univariate_function
univariate_function(
type,
parameters,
x,
inverse=False,
is_inverse=False,
confidence_level=None,
)Evaluate a univariate function.
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.
Parameters
| Name | Type | Description | Default |
|---|---|---|---|
| type | ('linear', 'power') | Matched case-insensitively. | "linear" |
| parameters | array_like | [alpha, beta, sigma] for "linear"; [alpha, beta, xi, sigma] for "power". sigma is still required (e.g. 0) when confidence_level is None – it only enters the calculation on the non-deterministic path. |
required |
| x | array_like | The values to evaluate the function at, or (when inverse=True) the values to evaluate the inverse function at. |
required |
| inverse | bool | If True, evaluates the inverse function (InverseFunction()) instead of the forward function (Function()). |
False |
| is_inverse | bool | "power"-only: PowerFunction’s own IsInverse property. An error for type="linear". |
False |
| confidence_level | float | If given, evaluates the non-deterministic path at this quantile level; if None (default), evaluates deterministically. |
None |
Returns
| Name | Type | Description |
|---|---|---|
| numpy.ndarray |
Examples
>>> from corehydropy import univariate_function
>>> univariate_function("linear", [0, 1, 0], [1, 2, 3])
array([1., 2., 3.])
>>> univariate_function("power", [5, 2, 0, 3], 6)
array([180.])
>>> univariate_function("power", [5, 2, 0, 3], 6, confidence_level=0.75)
array([1361.614084])