org.apache.commons.math3.fitting.leastsquares

## Class LeastSquaresFactory

- java.lang.Object
- - org.apache.commons.math3.fitting.leastsquares.LeastSquaresFactory

-     public class LeastSquaresFactory
      extends Object

  A Factory for creating `LeastSquaresProblem`s.
  Since:
    3.3
  Version:
    $Id: LeastSquaresFactory.java 1573307 2014-03-02 14:02:21Z luc $

- - ### Method Summary

    Methods
    Modifier and Type | Method and Description
    --- | ---
    `static LeastSquaresProblem` | `countEvaluations(LeastSquaresProblem problem, Incrementor counter)` Count the evaluations of a particular problem.
    `static LeastSquaresProblem` | `create(MultivariateJacobianFunction model, RealVector observed, RealVector start, ConvergenceChecker<LeastSquaresProblem.Evaluation> checker, int maxEvaluations, int maxIterations)` Create a `LeastSquaresProblem` from the given elements.
    `static LeastSquaresProblem` | `create(MultivariateJacobianFunction model, RealVector observed, RealVector start, RealMatrix weight, ConvergenceChecker<LeastSquaresProblem.Evaluation> checker, int maxEvaluations, int maxIterations)` Create a `LeastSquaresProblem` from the given elements.
    `static LeastSquaresProblem` | `create(MultivariateVectorFunction model, MultivariateMatrixFunction jacobian, double[] observed, double[] start, RealMatrix weight, ConvergenceChecker<LeastSquaresProblem.Evaluation> checker, int maxEvaluations, int maxIterations)` Create a `LeastSquaresProblem` from the given elements.
    `static ConvergenceChecker<LeastSquaresProblem.Evaluation>` | `evaluationChecker(ConvergenceChecker<PointVectorValuePair> checker)` View a convergence checker specified for a `PointVectorValuePair` as one specified for an `LeastSquaresProblem.Evaluation`.
    `static MultivariateJacobianFunction` | `model(MultivariateVectorFunction value, MultivariateMatrixFunction jacobian)` Combine a `MultivariateVectorFunction` with a `MultivariateMatrixFunction` to produce a `MultivariateJacobianFunction`.
    `static LeastSquaresProblem` | `weightDiagonal(LeastSquaresProblem problem, RealVector weights)` Apply a diagonal weight matrix to the `LeastSquaresProblem`.
    `static LeastSquaresProblem` | `weightMatrix(LeastSquaresProblem problem, RealMatrix weights)` Apply a dense weight matrix to the `LeastSquaresProblem`.

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Method Detail

    - #### create

          public static LeastSquaresProblem create(MultivariateJacobianFunction model,
                                   RealVector observed,
                                   RealVector start,
                                   ConvergenceChecker<LeastSquaresProblem.Evaluation> checker,
                                   int maxEvaluations,
                                   int maxIterations)

      Create a `LeastSquaresProblem` from the given elements. There will be no weights applied (Identity weights).
      Parameters:
        `model` - the model function. Produces the computed values.
        `observed` - the observed (target) values
        `start` - the initial guess.
        `checker` - convergence checker
        `maxEvaluations` - the maximum number of times to evaluate the model
        `maxIterations` - the maximum number to times to iterate in the algorithm
      Returns:
        the specified General Least Squares problem.

    - #### create

          public static LeastSquaresProblem create(MultivariateJacobianFunction model,
                                   RealVector observed,
                                   RealVector start,
                                   RealMatrix weight,
                                   ConvergenceChecker<LeastSquaresProblem.Evaluation> checker,
                                   int maxEvaluations,
                                   int maxIterations)

      Create a `LeastSquaresProblem` from the given elements.
      Parameters:
        `model` - the model function. Produces the computed values.
        `observed` - the observed (target) values
        `start` - the initial guess.
        `weight` - the weight matrix
        `checker` - convergence checker
        `maxEvaluations` - the maximum number of times to evaluate the model
        `maxIterations` - the maximum number to times to iterate in the algorithm
      Returns:
        the specified General Least Squares problem.

    - #### create

          public static LeastSquaresProblem create(MultivariateVectorFunction model,
                                   MultivariateMatrixFunction jacobian,
                                   double[] observed,
                                   double[] start,
                                   RealMatrix weight,
                                   ConvergenceChecker<LeastSquaresProblem.Evaluation> checker,
                                   int maxEvaluations,
                                   int maxIterations)

      Create a `LeastSquaresProblem` from the given elements.

      This factory method is provided for continuity with previous interfaces. Newer applications should use `create(MultivariateJacobianFunction, RealVector, RealVector, ConvergenceChecker, int, int)`, or `create(MultivariateJacobianFunction, RealVector, RealVector, RealMatrix, ConvergenceChecker, int, int)`.
      Parameters:
        `model` - the model function. Produces the computed values.
        `jacobian` - the jacobian of the model with respect to the parameters
        `observed` - the observed (target) values
        `start` - the initial guess.
        `weight` - the weight matrix
        `checker` - convergence checker
        `maxEvaluations` - the maximum number of times to evaluate the model
        `maxIterations` - the maximum number to times to iterate in the algorithm
      Returns:
        the specified General Least Squares problem.

    - #### weightMatrix

          public static LeastSquaresProblem weightMatrix(LeastSquaresProblem problem,
                                         RealMatrix weights)

      Apply a dense weight matrix to the `LeastSquaresProblem`.
      Parameters:
        `problem` - the unweighted problem
        `weights` - the matrix of weights
      Returns:
        a new `LeastSquaresProblem` with the weights applied. The original `problem` is not modified.

    - #### weightDiagonal

          public static LeastSquaresProblem weightDiagonal(LeastSquaresProblem problem,
                                           RealVector weights)

      Apply a diagonal weight matrix to the `LeastSquaresProblem`.
      Parameters:
        `problem` - the unweighted problem
        `weights` - the diagonal of the weight matrix
      Returns:
        a new `LeastSquaresProblem` with the weights applied. The original `problem` is not modified.

    - #### countEvaluations

          public static LeastSquaresProblem countEvaluations(LeastSquaresProblem problem,
                                             Incrementor counter)

      Count the evaluations of a particular problem. The `counter` will be incremented every time `LeastSquaresProblem.evaluate(RealVector)` is called on the returned problem.
      Parameters:
        `problem` - the problem to track.
        `counter` - the counter to increment.
      Returns:
        a least squares problem that tracks evaluations

    - #### evaluationChecker

          public static ConvergenceChecker<LeastSquaresProblem.Evaluation> evaluationChecker(ConvergenceChecker<PointVectorValuePair> checker)

      View a convergence checker specified for a `PointVectorValuePair` as one specified for an `LeastSquaresProblem.Evaluation`.
      Parameters:
        `checker` - the convergence checker to adapt.
      Returns:
        a convergence checker that delegates to `checker`.

    - #### model

          public static MultivariateJacobianFunction model(MultivariateVectorFunction value,
                                           MultivariateMatrixFunction jacobian)

      Combine a `MultivariateVectorFunction` with a `MultivariateMatrixFunction` to produce a `MultivariateJacobianFunction`.
      Parameters:
        `value` - the vector value function
        `jacobian` - the Jacobian function
      Returns:
        a function that computes both at the same time

Copyright © 2003–2014 The Apache Software Foundation. All rights reserved.