public class ScalarFirstOrderDifferentiator extends Object implements Differentiator<Double,Double,Double>
For a function $y = f(x)$ where $x$ and $y$ are scalars, this class produces a gradient function $g(x)$, i.e. a function that returns the gradient for each point $x$, where $g$ is the scalar $\frac{dy}{dx}$.
| Constructor and Description |
|---|
ScalarFirstOrderDifferentiator()
Creates an instance using the default value of eps (10-5) and central differencing type.
|
ScalarFirstOrderDifferentiator(FiniteDifferenceType differenceType)
Creates an instance using the default value of eps (10-5).
|
ScalarFirstOrderDifferentiator(FiniteDifferenceType differenceType,
double eps)
Creates an instance.
|
| Modifier and Type | Method and Description |
|---|---|
Function<Double,Double> |
differentiate(Function<Double,Double> function)
Provides a function that performs the differentiation.
|
Function<Double,Double> |
differentiate(Function<Double,Double> function,
Function<Double,Boolean> domain)
Provides a function that performs the differentiation.
|
public ScalarFirstOrderDifferentiator()
public ScalarFirstOrderDifferentiator(FiniteDifferenceType differenceType)
differenceType - the differencing type to be used in calculating the gradient functionpublic ScalarFirstOrderDifferentiator(FiniteDifferenceType differenceType, double eps)
If the size of the domain is very small or very large, consider re-scaling first. If this value is too small, the result will most likely be dominated by noise. Use around 10-5 times the domain size.
differenceType - the differencing type to be used in calculating the gradient functioneps - the step size used to approximate the derivativepublic Function<Double,Double> differentiate(Function<Double,Double> function)
Differentiatordifferentiate in interface Differentiator<Double,Double,Double>function - a function for which to get the differential functionpublic Function<Double,Double> differentiate(Function<Double,Double> function, Function<Double,Boolean> domain)
Differentiatordifferentiate in interface Differentiator<Double,Double,Double>function - a function for which to get the differential functiondomain - a function that returns false if the requested value is not in the domain, true otherwiseCopyright 2009-Present by OpenGamma Inc. and individual contributors
Apache v2 licensed
Additional documentation can be found at strata.opengamma.io.