View Javadoc
1   /*
2    * Copyright (C) 2015 Alberto Irurueta Carro (alberto@irurueta.com)
3    *
4    * Licensed under the Apache License, Version 2.0 (the "License");
5    * you may not use this file except in compliance with the License.
6    * You may obtain a copy of the License at
7    *
8    *         http://www.apache.org/licenses/LICENSE-2.0
9    *
10   * Unless required by applicable law or agreed to in writing, software
11   * distributed under the License is distributed on an "AS IS" BASIS,
12   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13   * See the License for the specific language governing permissions and
14   * limitations under the License.
15   */
16  package com.irurueta.numerical.fitting;
17  
18  import com.irurueta.numerical.EvaluationException;
19  
20  /**
21   * Interface to evaluate non-linear single dimensional functions.
22   * Evaluation of functions requires both function value at provided point x and
23   * function gradient respect to its parameters (i.e. derivatives respect to its
24   * parameters)
25   */
26  public interface LevenbergMarquardtSingleDimensionFunctionEvaluator {
27  
28      /**
29       * Creates array where estimated parameters will be stored.
30       * This array MUST contain the initial guessed solution for the Levenberg-
31       * Marquardt algorithm
32       *
33       * @return array where estimated parameters will be stored
34       */
35      double[] createInitialParametersArray();
36  
37      /**
38       * Evaluates a non-linear single dimension function at provided point using
39       * provided parameters and returns its evaluation and derivatives of the
40       * function respect the function parameters
41       *
42       * @param i           number of sample being evaluated
43       * @param point       point where function is evaluated
44       * @param params      initial parameters estimation to be tried. These will
45       *                    change as the Levenberg-Marquard algorithm iterates to the best solution.
46       *                    These are used as input parameters along with point to evaluate function
47       * @param derivatives partial derivatives of the function respect to each
48       *                    provided parameter
49       * @return function evaluation at provided point and using provided
50       * parameters
51       * @throws EvaluationException raised if something failed during the evaluation
52       */
53      double evaluate(final int i, final double point, final double[] params, final double[] derivatives)
54              throws EvaluationException;
55  }