public class Polynomial extends Object
| Modifier and Type | Field and Description | 
|---|---|
| double[] | coeffs | 
| Constructor and Description | 
|---|
| Polynomial(double[] coeffs)Create a new polynomial with the given coefficients. | 
| Polynomial(int order)Create a new polynomial of the requested order with all coefficients set to 0. | 
| Modifier and Type | Method and Description | 
|---|---|
| void | copyCoeffs(Polynomial other) | 
| static double[] | fitPolynomial(double[] data,
             int order)Fit a polynomial of the given order to the given data. | 
| static double[] | generatePolynomialValues(double[] coeffs,
                        int numSamples,
                        double a,
                        double b)For a polynomial with the given coefficients, compute  numSamplesvalues, equally spaced in the interval [a,
 b[. | 
| double[] | generatePolynomialValues(int numSamples,
                        double a,
                        double b)For a polynomial with the given coefficients, compute  numSamplesvalues, equally spaced in the interval [a,
 b[. | 
| int | getOrder() | 
| double | getValueAt(double x)For a polynomial with the given coefficients, compute the value at the given position. | 
| static double | getValueAt(double[] coeffs,
          double x)For a polynomial with the given coefficients, compute the value at the given position. | 
| static double[] | mean(double[][] p)Compute the mean polynomial from the given polynomials, by building a polynomial of the averaged coefficients. | 
| static float[] | mean(float[][] p)Compute the mean polynomial from the given polynomials, by building a polynomial of the averaged coefficients. | 
| static Polynomial | mean(Polynomial[] p)Compute the mean polynomial from the given polynomials, by building a polynomial of the averaged coefficients. | 
| static double | polynomialDistance(double[] coeffs1,
                  double[] coeffs2)Compute the integrated distance between two polynomials of same order. | 
| static double | polynomialDistance(float[] coeffs1,
                  float[] coeffs2)Compute the integrated distance between two polynomials of same order. | 
| double | polynomialDistance(Polynomial other)Compute the integrated distance between two polynomials of same order. | 
| static double | polynomialPearsonProductMomentCorr(double[] coeffs1,
                                  double[] coeffs2)Compute one minus the Pearson product moment correlation between two polynomials of same order. | 
| static double | polynomialSquaredDistance(double[] coeffs1,
                         double[] coeffs2)Compute the integral of the squared difference between two polynomials of same order. | 
| static double | polynomialSquaredDistance(float[] coeffs1,
                         float[] coeffs2)Compute the integral of the squared difference between two polynomials of same order. | 
| double | polynomialSquaredDistance(Polynomial other)Compute the integral of the squared difference between two polynomials of same order. | 
| static double | variance(double[][] p,
        double[] mean)For the given collection of polynomials, for which a mean polynomial has already been computed using
  mean(double[][]), compute a variance as follows. | 
| static double | variance(float[][] p,
        float[] mean)For the given collection of polynomials, for which a mean polynomial has already been computed using
  mean(float[][]), compute a variance as follows. | 
| static double | variance(Polynomial[] p,
        Polynomial mean)For the given collection of polynomials, for which a mean polynomial has already been computed using
  mean(Polynomial[]), compute a variance as follows. | 
public Polynomial(int order)
order - the polynomial order.public Polynomial(double[] coeffs)
coeffs - the polynomial coefficients. The code assumes that the polynomial is
            a_order t^order + a_(order-1) t^(order-1) + ... + a_1 t + a_0, and will interpret coeffs as
            a_order, a_(order-1), ..., a_1, a_0, where order is coeffs.length-1.public int getOrder()
public void copyCoeffs(Polynomial other)
public double[] generatePolynomialValues(int numSamples,
                                double a,
                                double b)
numSamples values, equally spaced in the interval [a,
 b[.numSamples - num samplesa - lower bound (inclusive)b - upper bound (exclusive)NullPointerException - if coeffs is nullIllegalArgumentException - if coeffs has length 0IllegalArgumentException - if numSamples is ≤ 0IllegalArgumentException - if a is not less than b.public double getValueAt(double x)
x - the position where to compute the valueNullPointerException - if coeffs is nullIllegalArgumentException - if coeffs has length 0public double polynomialDistance(Polynomial other)
other - polynomial with the same order as this polynomial.public double polynomialSquaredDistance(Polynomial other)
 This implements the algebraic solution proposed by Maxima from the following command:
 expand(integrate((sum(a[i]*x**i, i, 0, order))**2, x, 0, 1));, with order varied from 0 to 4. Increasing order
 by 1 adds (order+1) summands.
other - polynomial with the same order as this polynomial.public static double[] fitPolynomial(double[] data,
                     int order)
data - the data points, assumed to be in the interval [0, 1[order - the order of the polynomial. Must be non-negative.a_order t^order + a_(order-1) t^(order-1) + ... + a_1 t + a_0, then the array returned contains
         a_order, a_(order-1), ..., a_1, a_0. throws NullPointerException if data is null throws
         IllegalArgumentException if data.length < order or if order < 0.public static double[] generatePolynomialValues(double[] coeffs,
                                int numSamples,
                                double a,
                                double b)
numSamples values, equally spaced in the interval [a,
 b[.coeffs - the polynomial coefficients. The code assumes that the polynomial is
            a_order t^order + a_(order-1) t^(order-1) + ... + a_1 t + a_0, and will interpret coeffs as
            a_order, a_(order-1), ..., a_1, a_0, where order is coeffs.length-1.numSamples - num samplesa - lower bound (inclusive)b - upper bound (exclusive)NullPointerException - if coeffs is nullIllegalArgumentException - if coeffs has length 0IllegalArgumentException - if numSamples is ≤ 0IllegalArgumentException - if a is not less than b.public static double getValueAt(double[] coeffs,
                double x)
coeffs - the polynomial coefficients. The code assumes that the polynomial is
            a_order t^order + a_(order-1) t^(order-1) + ... + a_1 t + a_0, and will interpret coeffs as
            a_order, a_(order-1), ..., a_1, a_0, where order is coeffs.length-1.x - the position where to compute the valueNullPointerException - if coeffs is nullIllegalArgumentException - if coeffs has length 0public static Polynomial mean(Polynomial[] p)
p - the polynomials from which to compute the mean. they must all have the same orderpublic static double[] mean(double[][] p)
p - the polynomials from which to compute the mean. they must all have the same orderpublic static float[] mean(float[][] p)
p - the polynomials from which to compute the mean. they must all have the same orderpublic static double variance(Polynomial[] p, Polynomial mean)
mean(Polynomial[]), compute a variance as follows.
 
 
  V = 1/(p-1) * sum i from 0 to p-1 of integral from 0 to 1 of (p[i]-mean)^2; in other words, the sum of the
 squared distances (@see{#polynomialSquaredDistance()}) between each polynomial in p and the mean, divided by (p-1).
 
p - pmean - meanpublic static double variance(double[][] p,
              double[] mean)
mean(double[][]), compute a variance as follows.
 
 
  V = 1/(p-1) * sum i from 0 to p-1 of integral from 0 to 1 of (p[i]-mean)^2; in other words, the sum of the
 squared distances (@see{#polynomialSquaredDistance()}) between each polynomial in p and the mean, divided by (p-1).
 
p - pmean - meanpublic static double variance(float[][] p,
              float[] mean)
mean(float[][]), compute a variance as follows.
 
 
  V = 1/(p-1) * sum i from 0 to p-1 of integral from 0 to 1 of (p[i]-mean)^2; in other words, the sum of the
 squared distances (@see{#polynomialSquaredDistance()}) between each polynomial in p and the mean, divided by (p-1).
 
p - pmean - meanpublic static double polynomialDistance(double[] coeffs1,
                        double[] coeffs2)
coeffs1 - polynomial coefficients, [a_order, a_(order-1), ..., a_1, a_0]coeffs2 - polynomial coefficients, [a_order, a_(order-1), ..., a_1, a_0]public static double polynomialDistance(float[] coeffs1,
                        float[] coeffs2)
coeffs1 - polynomial coefficients, [a_order, a_(order-1), ..., a_1, a_0]coeffs2 - polynomial coefficients, [a_order, a_(order-1), ..., a_1, a_0]public static double polynomialSquaredDistance(double[] coeffs1,
                               double[] coeffs2)
 This implements the algebraic solution proposed by Maxima from the following command:
 expand(integrate((sum(a[i]*x**i, i, 0, order))**2, x, 0, 1));, with order varied from 0 to 4. Increasing order
 by 1 adds (order+1) summands.
coeffs1 - polynomial coefficients, [a_order, a_(order-1), ..., a_1, a_0]coeffs2 - polynomial coefficients, [a_order, a_(order-1), ..., a_1, a_0]public static double polynomialSquaredDistance(float[] coeffs1,
                               float[] coeffs2)
 This implements the algebraic solution proposed by Maxima from the following command:
 expand(integrate((sum(a[i]*x**i, i, 0, order))**2, x, 0, 1));, with order varied from 0 to 4. Increasing order
 by 1 adds (order+1) summands.
coeffs1 - polynomial coefficients, [a_order, a_(order-1), ..., a_1, a_0]coeffs2 - polynomial coefficients, [a_order, a_(order-1), ..., a_1, a_0]public static double polynomialPearsonProductMomentCorr(double[] coeffs1,
                                        double[] coeffs2)
 Equation: D = 1 - corr(F1 * F2)
 
coeffs1 - polynomial coefficients that are not nullcoeffs2 - polynomial coefficients that are not null coeffs1, coeffs2 are expected to be coefficients of same order
            polynomialsNullPointerException - if received polynomial coeffs nullIllegalArgumentException - if the length of coeffs are not equalCopyright © 2000–2016 DFKI GmbH. All rights reserved.