1 | /*
|
---|
2 | * Licensed to the Apache Software Foundation (ASF) under one or more
|
---|
3 | * contributor license agreements. See the NOTICE file distributed with
|
---|
4 | * this work for additional information regarding copyright ownership.
|
---|
5 | * The ASF licenses this file to You under the Apache License, Version 2.0
|
---|
6 | * (the "License"); you may not use this file except in compliance with
|
---|
7 | * the License. You may obtain a copy of the License at
|
---|
8 | *
|
---|
9 | * http://www.apache.org/licenses/LICENSE-2.0
|
---|
10 | *
|
---|
11 | * Unless required by applicable law or agreed to in writing, software
|
---|
12 | * distributed under the License is distributed on an "AS IS" BASIS,
|
---|
13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
---|
14 | * See the License for the specific language governing permissions and
|
---|
15 | * limitations under the License.
|
---|
16 | */
|
---|
17 | package agents.anac.y2019.harddealer.math3.fitting;
|
---|
18 |
|
---|
19 | import agents.anac.y2019.harddealer.math3.analysis.polynomials.PolynomialFunction;
|
---|
20 | import agents.anac.y2019.harddealer.math3.optim.nonlinear.vector.MultivariateVectorOptimizer;
|
---|
21 |
|
---|
22 | /**
|
---|
23 | * Polynomial fitting is a very simple case of {@link CurveFitter curve fitting}.
|
---|
24 | * The estimated coefficients are the polynomial coefficients (see the
|
---|
25 | * {@link #fit(double[]) fit} method).
|
---|
26 | *
|
---|
27 | * @since 2.0
|
---|
28 | * @deprecated As of 3.3. Please use {@link PolynomialCurveFitter} and
|
---|
29 | * {@link WeightedObservedPoints} instead.
|
---|
30 | */
|
---|
31 | @Deprecated
|
---|
32 | public class PolynomialFitter extends CurveFitter<PolynomialFunction.Parametric> {
|
---|
33 | /**
|
---|
34 | * Simple constructor.
|
---|
35 | *
|
---|
36 | * @param optimizer Optimizer to use for the fitting.
|
---|
37 | */
|
---|
38 | public PolynomialFitter(MultivariateVectorOptimizer optimizer) {
|
---|
39 | super(optimizer);
|
---|
40 | }
|
---|
41 |
|
---|
42 | /**
|
---|
43 | * Get the coefficients of the polynomial fitting the weighted data points.
|
---|
44 | * The degree of the fitting polynomial is {@code guess.length - 1}.
|
---|
45 | *
|
---|
46 | * @param guess First guess for the coefficients. They must be sorted in
|
---|
47 | * increasing order of the polynomial's degree.
|
---|
48 | * @param maxEval Maximum number of evaluations of the polynomial.
|
---|
49 | * @return the coefficients of the polynomial that best fits the observed points.
|
---|
50 | * @throws agents.anac.y2019.harddealer.math3.exception.TooManyEvaluationsException if
|
---|
51 | * the number of evaluations exceeds {@code maxEval}.
|
---|
52 | * @throws agents.anac.y2019.harddealer.math3.exception.ConvergenceException
|
---|
53 | * if the algorithm failed to converge.
|
---|
54 | */
|
---|
55 | public double[] fit(int maxEval, double[] guess) {
|
---|
56 | return fit(maxEval, new PolynomialFunction.Parametric(), guess);
|
---|
57 | }
|
---|
58 |
|
---|
59 | /**
|
---|
60 | * Get the coefficients of the polynomial fitting the weighted data points.
|
---|
61 | * The degree of the fitting polynomial is {@code guess.length - 1}.
|
---|
62 | *
|
---|
63 | * @param guess First guess for the coefficients. They must be sorted in
|
---|
64 | * increasing order of the polynomial's degree.
|
---|
65 | * @return the coefficients of the polynomial that best fits the observed points.
|
---|
66 | * @throws agents.anac.y2019.harddealer.math3.exception.ConvergenceException
|
---|
67 | * if the algorithm failed to converge.
|
---|
68 | */
|
---|
69 | public double[] fit(double[] guess) {
|
---|
70 | return fit(new PolynomialFunction.Parametric(), guess);
|
---|
71 | }
|
---|
72 | }
|
---|