org.jscience.physics.nuclear.kinematics.math.analysis.spanc
Class CalibrationFit

java.lang.Object
  extended by org.jscience.physics.nuclear.kinematics.math.analysis.spanc.CalibrationFit
All Implemented Interfaces:
java.io.Serializable

public class CalibrationFit
extends java.lang.Object
implements java.io.Serializable

Abstraction class for performing fits of channel versus rho data.

See Also:
Serialized Form

Constructor Summary
CalibrationFit()
          Creates new CalibrationFit object.
 
Method Summary
 double calculateFit(int index)
          Returns the QBrho value from the fit for the specified input peak.
 double getChannel0()
          Returns the (unweighted) mean of the input peak centroids, which is used as the offset of the channel axis for the purposes of the fit.
 UncertainNumber getCoefficient(int i)
          Returns the i'th order coefficient of the calibration fit and its uncertainty.
 double getCovariance(int i, int j)
          Gets a covariance matrix element.
 int getDataSize()
          Returns the number of input peaks fitted to.
 int getDOF()
          Returns the number of degrees of freedom in the fit, which is the number of input peaks minus the fit order minus 1.
 double getNormalizedResidual(int index)
          Returns the normalized residual for an input peak, which is the residual divided by its error bar.
 int getOrder()
          Gets the polynomial order of the calibration fit.
 double getPvalue()
          Gives the probability that the calibration actually describes the input data.
 double getReducedChiSq()
          Returns the calculated chi-square statistic divided by the degrees of freedom.
 double getResidual(int index)
          Returns the residual for an input peak.
 UncertainNumber getRho(UncertainNumber channel)
          Returns a rho value for a specified channel and uncertainty.
 boolean hasFit()
          Returns true if input data have been received, a fit order was set, and it was possible to do a fit with at least one degree of freedom.
 boolean setOrder(int n)
          Sets the fit order of the polynomial calibration, which causes the fit to be recalculated.
 java.lang.String toString()
          Gives more or less complete information about the input data and calibration curve.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

CalibrationFit

public CalibrationFit()
Creates new CalibrationFit object.

Method Detail

setOrder

public boolean setOrder(int n)
                 throws MathException
Sets the fit order of the polynomial calibration, which causes the fit to be recalculated.

Parameters:
n - order of the polynomial used to fit Ch. vs. QBrho
Returns:
boolean
Throws:
MathException - if fit fails

getNormalizedResidual

public double getNormalizedResidual(int index)
Returns the normalized residual for an input peak, which is the residual divided by its error bar.

Parameters:
index - which input peak to get residual for
Returns:
residual divided by its error bar

hasFit

public boolean hasFit()
Returns true if input data have been received, a fit order was set, and it was possible to do a fit with at least one degree of freedom.

Returns:
whether a fit is available

getCoefficient

public UncertainNumber getCoefficient(int i)
Returns the i'th order coefficient of the calibration fit and its uncertainty.

Parameters:
i - which order of coefficient to retrieve
Returns:
the i'th order coefficient

getCovariance

public double getCovariance(int i,
                            int j)
Gets a covariance matrix element.

Parameters:
i - row index
j - column index
Returns:
double covariance between i and j coefficients

getOrder

public int getOrder()
Gets the polynomial order of the calibration fit.

Returns:
the fit order

getResidual

public double getResidual(int index)
Returns the residual for an input peak.

Parameters:
index - which input peak to get residual for
Returns:
residual

getDataSize

public int getDataSize()
Returns the number of input peaks fitted to.

Returns:
number of input peaks

calculateFit

public double calculateFit(int index)
Returns the QBrho value from the fit for the specified input peak.

Parameters:
index - which input peak
Returns:
fit QBrho value

getDOF

public int getDOF()
Returns the number of degrees of freedom in the fit, which is the number of input peaks minus the fit order minus 1. I.e., there are fit order plus one parameters to a fit.

Returns:
degrees of freedom

getReducedChiSq

public double getReducedChiSq()
Returns the calculated chi-square statistic divided by the degrees of freedom.

Returns:
the reduced chi-square statistic from the fit

getChannel0

public double getChannel0()
Returns the (unweighted) mean of the input peak centroids, which is used as the offset of the channel axis for the purposes of the fit. This decouples the dominant linear term from the higher order terms as much as possible.

Returns:
unweighted mean mean channel

getRho

public UncertainNumber getRho(UncertainNumber channel)
                       throws StatisticsException,
                              MathException
Returns a rho value for a specified channel and uncertainty.

Parameters:
channel - centroid and uncertainty of a peak
Returns:
rho value and uncertainty from the calibration
Throws:
StatisticsException - if the calculation fails
MathException - if the calculation fails

getPvalue

public double getPvalue()
Gives the probability that the calibration actually describes the input data. In statistical terms, the probability that the chi-squared statistic would be it's current value or greater if the calibration curve is correct.

Returns:
p-value for the fit

toString

public java.lang.String toString()
Gives more or less complete information about the input data and calibration curve.

Overrides:
toString in class java.lang.Object
See Also:
Object.toString()