View Javadoc

1   /*
2    * SlopeInterceptLineFit.java
3    *
4    * Created on March 27, 2006, 3:19 PM
5    *
6    * $Id: SlopeInterceptLineFit.java,v 1.1 2006/03/28 04:51:03 ngraf Exp $
7    */
8   
9   package org.lcsim.fit.line;
10  /**
11   * The result of a fit to a 2-D line in slope-intercept form y=a+bx .
12   * @author Norman Graf
13   */
14  public class SlopeInterceptLineFit
15  {
16      private double _slope;
17      private double _intercept;
18      private double _sigA;
19      private double _sigB;
20      private double _sigAB;
21      private double _chisq;
22      private int _ndf;
23      /**
24       * Creates a new instance of SlopeInterceptLineFit
25       * 
26       * 
27       * @param slope The slope of the line.
28       * @param intercept The intercept of the line.
29       * @param slopeUncertainty The uncertainty on the slope
30       * @param interceptUncertainty The uncertainty on the intercept
31       * @param sigAB The covariance term.
32       * @param chisq The chi-squared of the fit
33       * @param ndf The number of degrees of freedom for the fit
34       */
35      public SlopeInterceptLineFit(double slope, double intercept, double slopeUncertainty, double interceptUncertainty, double sigAB, double chisq, int ndf)
36      {
37          _slope = slope;
38          _intercept = intercept;
39          _sigA = interceptUncertainty;        
40          _sigB = slopeUncertainty;
41          _sigAB = sigAB;
42          _chisq = chisq;
43          _ndf = ndf;
44      }
45      
46      /**
47       *
48       * @return The fit slope of the line.
49       */
50      public double slope()
51      {
52          return _slope;
53      }
54      
55      /**
56       * 
57       * @return The uncertainty on the fit slope of the line.
58       */
59      public double slopeUncertainty()
60      {
61          return _sigB;
62      }
63      
64      /**
65       *  
66       * @return The fit intercept of the line.
67       */
68      public double intercept()
69      {
70          return _intercept;
71      }
72      
73      /**
74       * 
75       * @return The uncertainty on the fit intercept of the line.
76       */
77      public double interceptUncertainty()
78      {
79          return _sigA;
80      }
81      
82      /**
83       * 
84       * @return The covariance of the slope-intercept uncertainties.
85       */
86      public double covariance()
87      {
88          return _sigAB;
89      }
90      
91      /**
92       * 
93       * @return The chi-squared of the fit.
94       */
95      public double chisquared()
96      {
97          return _chisq;
98      }
99      
100     /**
101      * 
102      * @return The number of degrees of freedom in the fit.
103      */
104     public int ndf()
105     {
106         return _ndf;
107     }
108  
109     public String toString()
110     {
111         StringBuffer sb = new StringBuffer("SlopeInterceptLineFit: \n");
112         sb.append("slope= "+_slope+" +/- "+_sigB+" intercept= "+_intercept+" +/- "+_sigA+" cov: "+_sigAB+ "\n");
113         sb.append("chi-squared for "+_ndf+" degrees of freedom is "+_chisq);
114         return sb.toString();
115     }
116 }