public class PSplineFitter extends Object
| Constructor and Description |
|---|
PSplineFitter() |
| Modifier and Type | Method and Description |
|---|---|
GeneralizedLeastSquareResults<double[]> |
solve(List<double[]> x,
List<Double> y,
List<Double> sigma,
double[] xa,
double[] xb,
int[] nKnots,
int[] degree,
double[] lambda,
int[] differenceOrder)
Given a set of data {x_i ,y_i} where each x_i is a vector and the y_i are scalars, we wish to find a function (represented
by B-splines) that fits the data while maintaining smoothness in each direction.
|
GeneralizedLeastSquareResults<Double> |
solve(List<Double> x,
List<Double> y,
List<Double> sigma,
double xa,
double xb,
int nKnots,
int degree,
double lambda,
int differenceOrder)
Fits a curve to x-y data.
|
public GeneralizedLeastSquareResults<Double> solve(List<Double> x, List<Double> y, List<Double> sigma, double xa, double xb, int nKnots, int degree, double lambda, int differenceOrder)
x - The independent variablesy - The dependent variablessigma - The error (or tolerance) on the y variablesxa - The lowest value of xxb - The highest value of xnKnots - Number of knots (note, the actual number of basis splines and thus fitted weights, equals nKnots + degree-1)degree - The degree of the basis function - 0 is piecewise constant, 1 is a sawtooth function
(i.e. two straight lines joined in the middle), 2 gives three
quadratic sections joined together, etc. For a large value of degree, the basis function tends to a gaussianlambda - The weight given to the penalty functiondifferenceOrder - applies the penalty the nth order difference in the weights,
so a differenceOrder of 2 will penalise large 2nd derivatives etcpublic GeneralizedLeastSquareResults<double[]> solve(List<double[]> x, List<Double> y, List<Double> sigma, double[] xa, double[] xb, int[] nKnots, int[] degree, double[] lambda, int[] differenceOrder)
x - The independent (vector) variables, as List<double[]>y - The dependent variables, as List<Double> ysigma - The error (or tolerance) on the y variablesxa - The lowest value of x in each dimensionxb - The highest value of x in each dimensionnKnots - Number of knots in each dimension (note, the actual number of basis splines and thus fitted weights,
equals nKnots + degree-1)degree - The degree of the basis function in each dimension - 0 is piecewise constant, 1 is a sawtooth function
(i.e. two straight lines joined in the middle), 2 gives three quadratic sections joined together, etc. For a large
value of degree, the basis function tends to a gaussianlambda - The weight given to the penalty function in each dimensiondifferenceOrder - applies the penalty the nth order difference in the weights, so a differenceOrder of 2
will penalize large 2nd derivatives etc. A difference differenceOrder can be used in each dimensionCopyright 2009-Present by OpenGamma Inc. and individual contributors
Apache v2 licensed
Additional documentation can be found at strata.opengamma.io.