bijnum
Class BIJfit

java.lang.Object
  extended by bijnum.BIJfit

public class BIJfit
extends java.lang.Object

This class implements useful linear and polynomial regression and root finding from Press, Flannery, Teukolsky, Vetterling, Numerical Recipes in C 2nd ed, Cambridge University Press, 1986 Copyright implementation (c) 1999-2004, Michael Abramoff. All rights reserved.


Field Summary
static double CGOLD
           
static int ITMAX
          ITMAX is the maximum allowed number of iterations; CGOLD is the golden ratio; ZEPS is a small number that protects against trying to achieve fractional accuracy for a minimum that happens to be exactly zero.
static double ZEPS
           
 
Constructor Summary
BIJfit()
           
 
Method Summary
static double[] linear(float[] x, float[] y)
          Given a line with points x, y, fit a line y = a1 + a2x through them with linear least squares regression.
static double[] minimumParabolic(float[] x, float[] y)
          Find the minimum y in a vector y (with x values in x) using parabolic interpolation and Brent's algorithm.
static double[] minimumStraight(float[] x, float[] y)
          Find the minimum value in a vector x,y.
static double[] poly(float[] x, float[] y)
          Given a line with points x, y, fit a line y = bx + a through them with linear least squares regression.
static double[] polynomialInterpolation(float[] xa, float[] ya, double x)
          From Press NR.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

ITMAX

public static final int ITMAX
ITMAX is the maximum allowed number of iterations; CGOLD is the golden ratio; ZEPS is a small number that protects against trying to achieve fractional accuracy for a minimum that happens to be exactly zero.

See Also:
Constant Field Values

CGOLD

public static final double CGOLD
See Also:
Constant Field Values

ZEPS

public static final double ZEPS
See Also:
Constant Field Values
Constructor Detail

BIJfit

public BIJfit()
Method Detail

linear

public static double[] linear(float[] x,
                              float[] y)
Given a line with points x, y, fit a line y = a1 + a2x through them with linear least squares regression.

Parameters:
x - a float array with x values.
y - a float array with y values.
Returns:
fit, a double[4] with fit[0] = a1, fit[1] = a2, fit[2] = var(a1), fit[3] = var(a2), where var(a) = STDEV(a)^2.

poly

public static double[] poly(float[] x,
                            float[] y)
Given a line with points x, y, fit a line y = bx + a through them with linear least squares regression.

Parameters:
x - a float array with x values.
y - a float array with y values.
Returns:
fit, a double[4] with fit[0] = a, fit[1] = b, fit[2] = var(a), fit[3] = var(b), where var(a) = STDEV(a)^2.

polynomialInterpolation

public static double[] polynomialInterpolation(float[] xa,
                                               float[] ya,
                                               double x)
                                        throws java.lang.Exception
From Press NR. Compute the polynomial interpolation of order xa.length at x for xa,ya. Return the interpolated value at x and the error.

Parameters:
xa - float[] x values of the function
ya - float[] y values of the function
x - double where the function should be interpolated.
Returns:
double[] with f(x) = [0] and the error dy at [1]
Throws:
java.lang.Exception

minimumStraight

public static double[] minimumStraight(float[] x,
                                       float[] y)
Find the minimum value in a vector x,y. This is the very simple case where only the elements of x,y are used.

Parameters:
x - float[] the x values of the vector
y - float[] the y values of the vector.
Returns:
double[2] the x value at minimum y in [0] and the minimum y at [1].

minimumParabolic

public static double[] minimumParabolic(float[] x,
                                        float[] y)
                                 throws java.lang.Exception
Find the minimum y in a vector y (with x values in x) using parabolic interpolation and Brent's algorithm.

Parameters:
x - float[] the x values of the vector
y - float[] the y values of the vector.
Returns:
double[2] the x value at minimum y in [0] and the minimum y at [1].
Throws:
java.lang.Exception