dwvisser.statistics
Class LinearFitErrY

java.lang.Object
  |
  +--dwvisser.statistics.LinearFitErrY

public class LinearFitErrY
extends java.lang.Object

Given a data set, performs a linear regression, then can be queried for the results. Based on code in Numerical Recipes in C

Author:
Dale Visser

Field Summary
 double[] residual
           
 
Constructor Summary
LinearFitErrY()
          do-nothing initializer to re-use this same code for multiple fits
LinearFitErrY(double[] x, double[] y)
          Creates and performs linear regression on unweighted data set.
LinearFitErrY(double[] x, double[] y, double[] sig)
          Creates and performs linear regression on weighted data set.
LinearFitErrY(java.io.File batch, java.io.File out)
           
 
Method Summary
 double calculateY(double x)
           
 void fit(double[] x, double[] y)
           
 void fit(double[] x, double[] y, double[] sig)
           
 double get_p_value()
           
 double getChiSq()
           
 int getDegreesOfFreedom()
           
 double getOffset()
           
 double getOffsetErr()
           
 double getReducedChiSq()
           
 double getSlope()
           
 double getSlopeErr()
           
 LinearFitErrY invertFit()
          Inverts x and y data sets.
static void main(java.lang.String[] args)
           
 java.lang.String toString()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

residual

public double[] residual
Constructor Detail

LinearFitErrY

public LinearFitErrY()
do-nothing initializer to re-use this same code for multiple fits


LinearFitErrY

public LinearFitErrY(double[] x,
                     double[] y,
                     double[] sig)
              throws StatisticsException
Creates and performs linear regression on weighted data set.

Parameters:
x - the x coordinates of the points
y - the y coordinates of the points
sig - the error bars on the y coordinates

LinearFitErrY

public LinearFitErrY(double[] x,
                     double[] y)
              throws StatisticsException
Creates and performs linear regression on unweighted data set.

Parameters:
x - the x coordinates of the points
y - the y coordinates of the points

LinearFitErrY

public LinearFitErrY(java.io.File batch,
                     java.io.File out)
              throws StatisticsException
Method Detail

fit

public void fit(double[] x,
                double[] y,
                double[] sig)
         throws StatisticsException
StatisticsException

fit

public void fit(double[] x,
                double[] y)
         throws StatisticsException
StatisticsException

getSlope

public double getSlope()

getSlopeErr

public double getSlopeErr()

getOffset

public double getOffset()

getOffsetErr

public double getOffsetErr()

getChiSq

public double getChiSq()

getReducedChiSq

public double getReducedChiSq()

getDegreesOfFreedom

public int getDegreesOfFreedom()

get_p_value

public double get_p_value()

calculateY

public double calculateY(double x)

invertFit

public LinearFitErrY invertFit()
                        throws StatisticsException
Inverts x and y data sets. X error bars are determined using sigy/y ratios. Useful for inverting linear calibrations of positive sets (e.g., silicon detector channel vs. energy).

StatisticsException

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object

main

public static void main(java.lang.String[] args)
Parameters:
args - the command line arguments