Class PSplineFitter
- java.lang.Object
-
- com.opengamma.strata.math.impl.interpolation.PSplineFitter
-
public class PSplineFitter extends Object
P-Spline fitter.
-
-
Constructor Summary
Constructors Constructor Description PSplineFitter()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method 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.
-
-
-
Method Detail
-
solve
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)
Fits a curve to x-y data.- Parameters:
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 etc- Returns:
- The results of the fit
-
solve
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)
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.- Parameters:
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 dimension- Returns:
- The results of the fit
-
-