Class GeneralizedLeastSquare


  • public class GeneralizedLeastSquare
    extends Object
    Generalized least square method.
    • Constructor Detail

      • GeneralizedLeastSquare

        public GeneralizedLeastSquare()
        Creates an instance.
    • Method Detail

      • solve

        public <T> GeneralizedLeastSquareResults<T> solve​(T[] x,
                                                          double[] y,
                                                          double[] sigma,
                                                          List<Function<T,​Double>> basisFunctions)
        Type Parameters:
        T - The type of the independent variables (e.g. Double, double[], DoubleArray etc)
        Parameters:
        x - independent variables
        y - dependent (scalar) variables
        sigma - (Gaussian) measurement error on dependent variables
        basisFunctions - set of basis functions - the fitting function is formed by these basis functions times a set of weights
        Returns:
        the results of the least square
      • solve

        public <T> GeneralizedLeastSquareResults<T> solve​(T[] x,
                                                          double[] y,
                                                          double[] sigma,
                                                          List<Function<T,​Double>> basisFunctions,
                                                          double lambda,
                                                          int differenceOrder)
        Generalised least square with penalty on (higher-order) finite differences of weights.
        Type Parameters:
        T - The type of the independent variables (e.g. Double, double[], DoubleArray etc)
        Parameters:
        x - independent variables
        y - dependent (scalar) variables
        sigma - (Gaussian) measurement error on dependent variables
        basisFunctions - set of basis functions - the fitting function is formed by these basis functions times a set of weights
        lambda - strength of penalty function
        differenceOrder - difference order between weights used in penalty function
        Returns:
        the results of the least square
      • solve

        public <T> GeneralizedLeastSquareResults<T> solve​(List<T> x,
                                                          List<Double> y,
                                                          List<Double> sigma,
                                                          List<Function<T,​Double>> basisFunctions)
        Type Parameters:
        T - The type of the independent variables (e.g. Double, double[], DoubleArray etc)
        Parameters:
        x - independent variables
        y - dependent (scalar) variables
        sigma - (Gaussian) measurement error on dependent variables
        basisFunctions - set of basis functions - the fitting function is formed by these basis functions times a set of weights
        Returns:
        the results of the least square
      • solve

        public <T> GeneralizedLeastSquareResults<T> solve​(List<T> x,
                                                          List<Double> y,
                                                          List<Double> sigma,
                                                          List<Function<T,​Double>> basisFunctions,
                                                          double lambda,
                                                          int differenceOrder)
        Generalised least square with penalty on (higher-order) finite differences of weights.
        Type Parameters:
        T - The type of the independent variables (e.g. Double, double[], DoubleArray etc)
        Parameters:
        x - independent variables
        y - dependent (scalar) variables
        sigma - (Gaussian) measurement error on dependent variables
        basisFunctions - set of basis functions - the fitting function is formed by these basis functions times a set of weights
        lambda - strength of penalty function
        differenceOrder - difference order between weights used in penalty function
        Returns:
        the results of the least square
      • solve

        public <T> GeneralizedLeastSquareResults<T> solve​(List<T> x,
                                                          List<Double> y,
                                                          List<Double> sigma,
                                                          List<Function<T,​Double>> basisFunctions,
                                                          int[] sizes,
                                                          double[] lambda,
                                                          int[] differenceOrder)
        Specialist method used mainly for solving multidimensional P-spline problems where the basis functions (B-splines) span a N-dimension space, and the weights sit on an N-dimension grid and are treated as a N-order tensor rather than a vector, so k-order differencing is done for each tensor index while varying the other indices.
        Type Parameters:
        T - The type of the independent variables (e.g. Double, double[], DoubleArray etc)
        Parameters:
        x - independent variables
        y - dependent (scalar) variables
        sigma - (Gaussian) measurement error on dependent variables
        basisFunctions - set of basis functions - the fitting function is formed by these basis functions times a set of weights
        sizes - The size the weights tensor in each dimension (the product of this must equal the number of basis functions)
        lambda - strength of penalty function in each dimension
        differenceOrder - difference order between weights used in penalty function for each dimension
        Returns:
        the results of the least square