util.wavelet
Class GaussianFit

java.lang.Object
  extended by util.wavelet.GaussianFit
All Implemented Interfaces:
Function

public class GaussianFit
extends Object
implements Function

A function representing a gaussian to be used in AnalyticProblems.marquardt(int, int, float[], float[], float[][], numal.lowprecision.Function, float[]).

Author:
John Talbot

Constructor Summary
GaussianFit(float[] x, float[] y)
           
 
Method Summary
 void computeJacobian(int m, int n, float[] parameter, float[] rv, float[][] jac)
          Get the partial derivatives jac[i][j] = drv[i]/dpar[j], obtained with the current values of the parameters.
 boolean computeResidualVector(int m, int n, float[] parameter, float[] rv)
          Get residual vector rv[i] = f(x[i],par) - y[i].
static float f(float x, float[] parameter)
          Get the value of this function for a given abcissa and parameters.
 float getAbsoluteTolerance()
          Absolute tolerance for the difference between the Euclidian norm of the ultimate and penultimate residual vector (value of epsilon_a) the process is terminated if the improvement of the sum of the squares is less than relativeTolerance*(sum of the squares)+absoluteTolerance*absoluteTolerance
 float[] getAnalyticValues(int m, float[] parameter)
          Get the analytic values of the function for the given set of parameters and for all abcissa.
 int getInvocations()
          Maximum allowed number of invocations of Function.computeResidualVector(int, int, float[], float[])
 float getMachinePrecision()
          Machine precision
 float getRelativeTolerance()
          Relative tolerance for the difference between the Euclidian norm of the ultimate and penultimate residual vector (value of epsilon_re) (see absoluteTolerance)
 float getStartingValue()
          Starting value used for the relation between the gradient and the Gauss-Newton direction (value of ξ); if the problem is well conditioned then a suitable value for startingValue will be 0.01; if the problem is ill conditioned then startingValue should be greater, but the value of startingValue must satisfy : machinePrecision < startingValue ≤ 1 / machinePrecision
static float getX(int pixel)
          Get the wavelength as a function of SDSS spectra pixel.
static void main(String[] args)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

GaussianFit

public GaussianFit(float[] x,
                   float[] y)
Method Detail

getX

public static float getX(int pixel)
Get the wavelength as a function of SDSS spectra pixel. The function is 10^(C0 + pixel*C1).

Parameters:
pixel - an integer representing the position in the SDSS spectra
Returns:
wavelength

main

public static void main(String[] args)

f

public static float f(float x,
                      float[] parameter)
Get the value of this function for a given abcissa and parameters.

Parameters:
x - abcissa at which this function is to be evaluated
parameter - array of function parameters
Returns:
the value of this function for the given x and parameters

getAnalyticValues

public float[] getAnalyticValues(int m,
                                 float[] parameter)
Description copied from interface: Function
Get the analytic values of the function for the given set of parameters and for all abcissa.

Specified by:
getAnalyticValues in interface Function
Parameters:
m - number of sample points used in the fitting
parameter - an array of function parameters
Returns:
the value of this function for all abcissa and parameters

computeResidualVector

public boolean computeResidualVector(int m,
                                     int n,
                                     float[] parameter,
                                     float[] rv)
Description copied from interface: Function
Get residual vector rv[i] = f(x[i],par) - y[i]. POSTCONDITION: parameter array must not be altered.

Specified by:
computeResidualVector in interface Function
Parameters:
m - number of sample points used in the fitting
n - number of parameters, must be less than or equal to m
parameter - input: current values of parameters (shouldn't be altered by funct)
rv - output: residual vector obtained with current value of parameters; i.e f(x[i],par) - y[i]
Returns:
true when successful, false if current estimates of parameters lie outside a feasible region (invoker can avoid residual vector calculations on values which may make no sense or even cause overflow)

computeJacobian

public void computeJacobian(int m,
                            int n,
                            float[] parameter,
                            float[] rv,
                            float[][] jac)
Description copied from interface: Function
Get the partial derivatives jac[i][j] = drv[i]/dpar[j], obtained with the current values of the parameters. The precision of this method in computing the elements of jac must be at least the precision defined by in[3] and in[4] of AnalyticProblems.marquardt(int, int, float[], float[], float[][], numal.lowprecision.Function, float[]). POSTCONDITION: parameter array must not be altered.

Specified by:
computeJacobian in interface Function
Parameters:
m - number of sample points used in the fitting
n - number of parameters, must be less than or equal to the number of sample points
parameter - input: current values of parameters
rv - output: residual vector obtained with current value of parameters; i.e f(x[i],parameter) - y[i]
jac - output: partial derivatives drv[i]/dparameter[j], obtained with the current values of the parameters

getInvocations

public int getInvocations()
Description copied from interface: Function
Maximum allowed number of invocations of Function.computeResidualVector(int, int, float[], float[])

Specified by:
getInvocations in interface Function

getMachinePrecision

public float getMachinePrecision()
Description copied from interface: Function
Machine precision

Specified by:
getMachinePrecision in interface Function

getRelativeTolerance

public float getRelativeTolerance()
Description copied from interface: Function
Relative tolerance for the difference between the Euclidian norm of the ultimate and penultimate residual vector (value of epsilon_re) (see absoluteTolerance)

Specified by:
getRelativeTolerance in interface Function

getAbsoluteTolerance

public float getAbsoluteTolerance()
Description copied from interface: Function
Absolute tolerance for the difference between the Euclidian norm of the ultimate and penultimate residual vector (value of epsilon_a) the process is terminated if the improvement of the sum of the squares is less than relativeTolerance*(sum of the squares)+absoluteTolerance*absoluteTolerance

Specified by:
getAbsoluteTolerance in interface Function

getStartingValue

public float getStartingValue()
Description copied from interface: Function
Starting value used for the relation between the gradient and the Gauss-Newton direction (value of ξ); if the problem is well conditioned then a suitable value for startingValue will be 0.01; if the problem is ill conditioned then startingValue should be greater, but the value of startingValue must satisfy : machinePrecision < startingValue ≤ 1 / machinePrecision

Specified by:
getStartingValue in interface Function