Class PSplineFitter


  • public class PSplineFitter
    extends Object
    P-Spline fitter.
    • Constructor Detail

      • PSplineFitter

        public PSplineFitter()
    • 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 variables
        y - The dependent variables
        sigma - The error (or tolerance) on the y variables
        xa - The lowest value of x
        xb - The highest value of x
        nKnots - 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 gaussian
        lambda - The weight given to the penalty function
        differenceOrder - 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> y
        sigma - The error (or tolerance) on the y variables
        xa - The lowest value of x in each dimension
        xb - The highest value of x in each dimension
        nKnots - 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 gaussian
        lambda - The weight given to the penalty function in each dimension
        differenceOrder - 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