Curve

A curve is a mathematical function transforming one value into another one. Grail’s curves operate on floating point numbers (R→R). They are often used in Grail’s utility evaluators.

A user can inherit from Curve class to create their own custom curves or they can make use of Grail’s built-in curve types.

Basic Curves

Let’s assume that x means input value.

Constant Function

Parameters
  • value

This function returns value disregarding it’s input.

Constant Function

Step Function

Parameters
  • threshold

  • beforeThresholdValue

  • afterThresholdValue

This function returns afterThresholdValue if x is greater than threshold. Otherwise returns beforeThresholdValue.

Step Function

Linear Function

Parameters
  • slope

  • intercept

This functions returns result of operation slope * x + intercept.

Linear Function

Power Function

Parameters
  • exponent

  • slope

  • intercept

This function takes linear function and raises it to power determined by exponent The result of linear function slope * x + intercept is lowerbound by 0.

Power Function

Exponential Function

Parameters
  • base

This function raises base to `x’th power.

Exponential Function

Sigmoid Function

Parameters
  • slope

  • threshold

Work in progress. One day it will become a properly working sigmoid function.

Sigmoid Function

Linearly Interpolated Curve

Simple linear interpolation applied to a set of points (from R2).

Linearly Interpolated Curve

Bezier Spline

This is a bezier spline created based on a set of waypoints and velocities coming in and out of them.

Bezier Spline

Staircase Function

Piecewise constant function with finite amount of pieces.

Staircase Function

Bounded Curves

Lowerbound

Lowerbound curves cannot return result lesser than their lowerValue.

Lowerbound Power Function
  • C++

  • C#

auto lowerbound = LowerBound<LinearFunction>{lowerValue, gradient, intercept};
Curve linearCurve = new LinearFunction(gradient, intercept);
LowerBound lowerbound = new LowerBound(linearCurve, lowerValue);

Upperbound

Upperbound curves cannot return result greater than their upperValue.

Upperbound Power Function
  • C++

  • C#

auto upperbound = UpperBound<LinearFunction>{upperValue, gradient, intercept};
Curve linearCurve = new LinearFunctiongradient, intercept);
UpperBound upperbound = new UpperBound(linearCurve, upperValue);

Double-Bounded

Double-bounded curves cannot return results lesser than lowerValue or greater than upperValue.

Double-Bounded Power Function
  • C++

  • C#

auto doubleBounded = BoundedCurve<LinearFunction>{lowerValue, upperValue, gradient, intercept};
Curve linearCurve = new LinearFunction(gradient, intercept);
BoundedCurve doubleBounded = new BoundedCurve(linearCurve, lowerValue, upperValue);