[Kst] kdeextragear-2/kst/plugins/linefit

George Staikos staikos at kde.org
Fri May 23 21:09:45 CEST 2003


CVS commit by staikos: 

pass in a, b, chi^2 as scalars


  M +11 -2     linefit.c   1.4
  M +9 -0      linefit.xml   1.3


--- kdeextragear-2/kst/plugins/linefit/linefit.c  #1.3:1.4
@@ -15,8 +15,8 @@ int linefit(const double *const inArrays
                 const double is[],
                 double *outArrays[], int outArrayLens[],
-                double os[])
+                double outScalars[])
 {
         int i = 0;
-        double a = 0.0, b = 0.0, sx = 0.0, sy = 0.0, sxoss = 0.0, st2 = 0.0;
+        double a = 0.0, b = 0.0, sx = 0.0, sy = 0.0, sxoss = 0.0, st2 = 0.0, chi2 = 0.0;
 
         if (inArrayLens[X] != inArrayLens[Y]) {
@@ -54,4 +54,13 @@ int linefit(const double *const inArrays
         outArrays[Y][0] = a+b*outArrays[X][0];
         outArrays[Y][1] = a+b*outArrays[X][1];
+
+        for (i = 0; i < inArrayLens[X]; i++) {
+                double z = inArrays[Y][i] - a - b*inArrays[X][i];
+                chi2 += z*z;
+        }
+
+        outScalars[0] = a;
+        outScalars[1] = b;
+        outScalars[2] = chi2;
 
         return 0;

--- kdeextragear-2/kst/plugins/linefit/linefit.xml  #1.2:1.3
@@ -24,4 +24,13 @@
 <table type="float" name="Y Interpolated" descr="The array of Y coordinates output.  This will be of size 2 to indicate the endpoints of the line." />
 </output>
+<output>
+<float name="a" descr="The a value in the interpolation equation y = a + b*x." />
+</output>
+<output>
+<float name="b" descr="The b value in the interpolation equation y = a + b*x." />
+</output>
+<output>
+<float name="chi^2" descr="The chi-square result of the interpolation." />
+</output>
 </interface>
 </module>




More information about the Kst mailing list