Class DoubleRangeLimitTransform
- java.lang.Object
-
- com.opengamma.strata.math.impl.minimization.DoubleRangeLimitTransform
-
- All Implemented Interfaces:
ParameterLimitsTransform
public class DoubleRangeLimitTransform extends Object implements ParameterLimitsTransform
Limit transform.If a model parameter $x$ is constrained to be between two values $a \geq x \geq b$, the function to transform it to an unconstrained variable is $y$ is given by $$ \begin{align*} y &= \tanh^{-1}\left(\frac{x - m}{s}\right)\\ m &= \frac{a + b}{2}\\ s &= \frac{b - a}{2} \end{align*} $$ with the inverse transform $$ \begin{align*} x &= s\tanh(y) + m\\ \end{align*} $$
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from interface com.opengamma.strata.math.impl.minimization.ParameterLimitsTransform
ParameterLimitsTransform.LimitType
-
-
Constructor Summary
Constructors Constructor Description DoubleRangeLimitTransform(double lower, double upper)Creates an instance.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description booleanequals(Object obj)inthashCode()doubleinverseTransform(double y)If $y > 25$, this returns $b$.doubleinverseTransformGradient(double y)If $|y| > 25$, this returns 0.doubletransform(double x)A function to transform a constrained model parameter (y) to an unconstrained fitting parameter (y*) - i.e.doubletransformGradient(double x)The gradient of the function used to transform from a model parameter that is only allows to take certain values, to a fitting parameter that can take any value.
-
-
-
Constructor Detail
-
DoubleRangeLimitTransform
public DoubleRangeLimitTransform(double lower, double upper)Creates an instance.- Parameters:
lower- Lower limitupper- Upper limit- Throws:
IllegalArgumentException- If the upper limit is not greater than the lower limit
-
-
Method Detail
-
inverseTransform
public double inverseTransform(double y)
If $y > 25$, this returns $b$. If $y < -25$ returns $a$. A function to transform an unconstrained fitting parameter (y*) to a constrained model parameter (y) - i.e. y = f^-1(y*)- Specified by:
inverseTransformin interfaceParameterLimitsTransform- Parameters:
y- Fitting parameter- Returns:
- Model parameter
-
transform
public double transform(double x)
A function to transform a constrained model parameter (y) to an unconstrained fitting parameter (y*) - i.e. y* = f(y)- Specified by:
transformin interfaceParameterLimitsTransform- Parameters:
x- Model parameter- Returns:
- Fitting parameter
- Throws:
IllegalArgumentException- If $x > b$ or $x < a$
-
inverseTransformGradient
public double inverseTransformGradient(double y)
If $|y| > 25$, this returns 0. The gradient of the function used to transform from a fitting parameter that can take any value, to a model parameter that is only allows to take certain values.- Specified by:
inverseTransformGradientin interfaceParameterLimitsTransform- Parameters:
y- fitting parameter- Returns:
- the gradient
-
transformGradient
public double transformGradient(double x)
The gradient of the function used to transform from a model parameter that is only allows to take certain values, to a fitting parameter that can take any value.- Specified by:
transformGradientin interfaceParameterLimitsTransform- Parameters:
x- Model parameter- Returns:
- the gradient
- Throws:
IllegalArgumentException- If $x > b$ or $x < a$
-
-