Index: /trunk/psLib/src/dataManip/psStats.c
===================================================================
--- /trunk/psLib/src/dataManip/psStats.c	(revision 4137)
+++ /trunk/psLib/src/dataManip/psStats.c	(revision 4138)
@@ -9,6 +9,11 @@
  *  @author GLG, MHPCC
  *
- *  @version $Revision: 1.130 $ $Name: not supported by cvs2svn $
- *  @date $Date: 2005-06-03 22:30:20 $
+ *  XXX: The following stats members are never used, or set in this code.
+ *      stats->robustN50
+ *      stats->clippedNvalues
+ *      stats->binsize
+ *
+ *  @version $Revision: 1.131 $ $Name: not supported by cvs2svn $
+ *  @date $Date: 2005-06-07 23:11:54 $
  *
  *  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
@@ -1629,4 +1634,6 @@
             (stats->options & PS_STAT_ROBUST_STDEV)) {
         // We fit a 1-D polynomial to the data.
+        // XXX: I implement the changes requested in bug 366.  However, this
+        // code no longer produces sensible results.
         // XXX: Since we are no longer fitting a 1-D Gaussian, we can probably
         // remove some of theabove code that calculated the initial estimate
@@ -1634,4 +1641,5 @@
 
         psVector *y = psVectorAlloc(2 * dL + 1, PS_TYPE_F32);
+        psVector *x = psVectorAlloc(2 * dL + 1, PS_TYPE_F32);
         for (i = modeBinNum - dL; i <= modeBinNum + dL; i++) {
             int index = i - modeBinNum + dL;
@@ -1639,4 +1647,5 @@
             y->data.F32[index] = robustHistogramVector->data.F32[i];
             //            y->data.F32[index] = logf(robustHistogramVector->data.F32[i]);
+            x->data.F32[index] = (psF32) index;
         }
 
@@ -1659,4 +1668,17 @@
             stats->robustStdev = polyFitSigma;
         }
+        // For testing only.  This shows that the polynomial fit is successful.
+        if (0) {
+            printf("--- Results of the 1-D polynomial fit:\n");
+            for (i = modeBinNum - dL; i <= modeBinNum + dL; i++) {
+                int index = i - modeBinNum + dL;
+                printf("(x, y, poly(x)) is (%.2f, %.2f, %.2f)\n",
+                       x->data.F32[index],
+                       y->data.F32[index],
+                       psPolynomial1DEval(tmpPoly, x->data.F32[index]));
+            }
+        }
+
+        psFree(x);
         psFree(y);
         psFree(tmpPoly);
@@ -1750,13 +1772,14 @@
     newStruct->robustUQ = NAN;
     newStruct->robustLQ = NAN;
-    newStruct->robustN50 = 0;
-    newStruct->robustNfit = 0;
+    newStruct->robustN50 = -1;            // XXX: This is never used
+    newStruct->robustNfit = -1;
     newStruct->clippedMean = NAN;
     newStruct->clippedStdev = NAN;
+    newStruct->clippedNvalues = -1;     // XXX: This is never used
     newStruct->clipSigma = 3.0;
-    newStruct->clipIter = 3.0;
+    newStruct->clipIter = 3;
     newStruct->min = NAN;
     newStruct->max = NAN;
-    newStruct->binsize = NAN;
+    newStruct->binsize = NAN;          // XXX: This is never used
     newStruct->options = options;
 
Index: /trunk/psLib/src/dataManip/psStats.h
===================================================================
--- /trunk/psLib/src/dataManip/psStats.h	(revision 4137)
+++ /trunk/psLib/src/dataManip/psStats.h	(revision 4138)
@@ -1,15 +1,19 @@
-
 /** @file  psStats.h
  *  \brief basic statistical operations
  *  @ingroup Stats
  *
-xd *  This file will hold the definition of the histogram and stats data
+ *  This file will hold the definition of the histogram and stats data
  *  structures.  It also contains prototypes for procedures which operate
  *  on those data structures.
  *
- *  @author George Gusciora, MHPCC
+ *  XXX: The following stats members are never used, or set in this code.
+ *      stats->robustN50
+ *      stats->clippedNvalues
+ *      stats->binsize
  *
- *  @version $Revision: 1.40 $ $Name: not supported by cvs2svn $
- *  @date $Date: 2005-03-29 22:34:59 $
+ *  @author GLG, MHPCC
+ *
+ *  @version $Revision: 1.41 $ $Name: not supported by cvs2svn $
+ *  @date $Date: 2005-06-07 23:11:54 $
  *
  *  Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii
@@ -67,15 +71,15 @@
     psF64 robustUQ;            ///< robust upper quartile
     psF64 robustLQ;            ///< robust lower quartile
-    psS32 robustN50;              ///<
-    psS32 robustNfit;             ///<
+    psS32 robustN50;           ///< Number of points in Gaussian fit.  XXX: This is currently never set.
+    psS32 robustNfit;          ///< The number of points between the quartiles.
     psF64 clippedMean;         ///< Nsigma clipped mean
     psF64 clippedStdev;        ///< standard deviation after clipping
-    psS32 clippedNvalues;         ///< ???
+    psS32 clippedNvalues;      ///< Number of data points used for clipped mean:  This value is never used.
     psF64 clipSigma;           ///< Nsigma used for clipping; user input
-    psS32 clipIter;               ///< Number of clipping iterations; user input
+    psS32 clipIter;            ///< Number of clipping iterations; user input
     psF64 min;                 ///< minimum data value in array
     psF64 max;                 ///< maximum data value in array
-    psF64 binsize;             ///<
-    psStatsOptions options;     ///< bitmask of calculated values
+    psF64 binsize;             ///< binsize for robust fit (input/ouput)
+    psStatsOptions options;    ///< bitmask of calculated values
 }
 psStats;
@@ -86,9 +90,9 @@
  */
 psStats* psVectorStats(
-    psStats* stats,    ///< stats structure defines stats to be calculated and how
+    psStats* stats,          ///< stats structure defines stats to be calculated and how
     const psVector* in,      ///< Vector to be analysed.
     const psVector* errors,  ///< Errors.
     const psVector* mask,    ///< Ignore elements where (maskVector & maskVal) != 0: must be INT or NULL
-    psU32 maskVal      ///< Only mask elements with one of these bits set in maskVector
+    psU32 maskVal            ///< Only mask elements with one of these bits set in maskVector
 );
 
@@ -119,7 +123,7 @@
     psVector* bounds;                  ///< Bounds for the bins (type F32)
     psVector* nums;                    ///< Number in each of the bins (INT)
-    psS32 minNum;                        ///< Number below the minimum
-    psS32 maxNum;                        ///< Number above the maximum
-    psBool uniform;                      ///< Is it a uniform distribution?
+    psS32 minNum;                      ///< Number below the minimum
+    psS32 maxNum;                      ///< Number above the maximum
+    psBool uniform;                    ///< Is it a uniform distribution?
 }
 psHistogram;
@@ -134,5 +138,5 @@
     psF32 lower,                       ///< Lower limit for the bins
     psF32 upper,                       ///< Upper limit for the bins
-    psS32 n                              ///< Number of bins
+    psS32 n                            ///< Number of bins
 );
 
@@ -165,15 +169,15 @@
  *
  *  @return psBool    If more than one statistic result is set in stats->options,
- *                  false is returned and the value parameter is not set, 
- *                  otherwise true is returned.
+ *                    false is returned and the value parameter is not set, 
+ *                    otherwise true is returned.
  */
 psBool p_psGetStatValue(
-    const psStats* stats,
-    ///< the statistic struct to operate on
+    const psStats* stats, ///< the statistic struct to operate on
 
-    psF64 *value
-    ///< if return is true, this is set to the specified statistic value by stats->options
+    psF64 *value ///< if return is true, this is set to the specified statistic value by stats->options
 );
 
+// XXX: Create a single, generic, version of the vector normalize function.
+// XXX: Ask IfA for a public psLib function.
 void p_psNormalizeVectorRangeU8(psVector* myData, psU8 low, psU8 high);
 void p_psNormalizeVectorRangeU16(psVector* myData, psU16 low, psU16 high);
Index: /trunk/psLib/src/math/psStats.c
===================================================================
--- /trunk/psLib/src/math/psStats.c	(revision 4137)
+++ /trunk/psLib/src/math/psStats.c	(revision 4138)
@@ -9,6 +9,11 @@
  *  @author GLG, MHPCC
  *
- *  @version $Revision: 1.130 $ $Name: not supported by cvs2svn $
- *  @date $Date: 2005-06-03 22:30:20 $
+ *  XXX: The following stats members are never used, or set in this code.
+ *      stats->robustN50
+ *      stats->clippedNvalues
+ *      stats->binsize
+ *
+ *  @version $Revision: 1.131 $ $Name: not supported by cvs2svn $
+ *  @date $Date: 2005-06-07 23:11:54 $
  *
  *  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
@@ -1629,4 +1634,6 @@
             (stats->options & PS_STAT_ROBUST_STDEV)) {
         // We fit a 1-D polynomial to the data.
+        // XXX: I implement the changes requested in bug 366.  However, this
+        // code no longer produces sensible results.
         // XXX: Since we are no longer fitting a 1-D Gaussian, we can probably
         // remove some of theabove code that calculated the initial estimate
@@ -1634,4 +1641,5 @@
 
         psVector *y = psVectorAlloc(2 * dL + 1, PS_TYPE_F32);
+        psVector *x = psVectorAlloc(2 * dL + 1, PS_TYPE_F32);
         for (i = modeBinNum - dL; i <= modeBinNum + dL; i++) {
             int index = i - modeBinNum + dL;
@@ -1639,4 +1647,5 @@
             y->data.F32[index] = robustHistogramVector->data.F32[i];
             //            y->data.F32[index] = logf(robustHistogramVector->data.F32[i]);
+            x->data.F32[index] = (psF32) index;
         }
 
@@ -1659,4 +1668,17 @@
             stats->robustStdev = polyFitSigma;
         }
+        // For testing only.  This shows that the polynomial fit is successful.
+        if (0) {
+            printf("--- Results of the 1-D polynomial fit:\n");
+            for (i = modeBinNum - dL; i <= modeBinNum + dL; i++) {
+                int index = i - modeBinNum + dL;
+                printf("(x, y, poly(x)) is (%.2f, %.2f, %.2f)\n",
+                       x->data.F32[index],
+                       y->data.F32[index],
+                       psPolynomial1DEval(tmpPoly, x->data.F32[index]));
+            }
+        }
+
+        psFree(x);
         psFree(y);
         psFree(tmpPoly);
@@ -1750,13 +1772,14 @@
     newStruct->robustUQ = NAN;
     newStruct->robustLQ = NAN;
-    newStruct->robustN50 = 0;
-    newStruct->robustNfit = 0;
+    newStruct->robustN50 = -1;            // XXX: This is never used
+    newStruct->robustNfit = -1;
     newStruct->clippedMean = NAN;
     newStruct->clippedStdev = NAN;
+    newStruct->clippedNvalues = -1;     // XXX: This is never used
     newStruct->clipSigma = 3.0;
-    newStruct->clipIter = 3.0;
+    newStruct->clipIter = 3;
     newStruct->min = NAN;
     newStruct->max = NAN;
-    newStruct->binsize = NAN;
+    newStruct->binsize = NAN;          // XXX: This is never used
     newStruct->options = options;
 
Index: /trunk/psLib/src/math/psStats.h
===================================================================
--- /trunk/psLib/src/math/psStats.h	(revision 4137)
+++ /trunk/psLib/src/math/psStats.h	(revision 4138)
@@ -1,15 +1,19 @@
-
 /** @file  psStats.h
  *  \brief basic statistical operations
  *  @ingroup Stats
  *
-xd *  This file will hold the definition of the histogram and stats data
+ *  This file will hold the definition of the histogram and stats data
  *  structures.  It also contains prototypes for procedures which operate
  *  on those data structures.
  *
- *  @author George Gusciora, MHPCC
+ *  XXX: The following stats members are never used, or set in this code.
+ *      stats->robustN50
+ *      stats->clippedNvalues
+ *      stats->binsize
  *
- *  @version $Revision: 1.40 $ $Name: not supported by cvs2svn $
- *  @date $Date: 2005-03-29 22:34:59 $
+ *  @author GLG, MHPCC
+ *
+ *  @version $Revision: 1.41 $ $Name: not supported by cvs2svn $
+ *  @date $Date: 2005-06-07 23:11:54 $
  *
  *  Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii
@@ -67,15 +71,15 @@
     psF64 robustUQ;            ///< robust upper quartile
     psF64 robustLQ;            ///< robust lower quartile
-    psS32 robustN50;              ///<
-    psS32 robustNfit;             ///<
+    psS32 robustN50;           ///< Number of points in Gaussian fit.  XXX: This is currently never set.
+    psS32 robustNfit;          ///< The number of points between the quartiles.
     psF64 clippedMean;         ///< Nsigma clipped mean
     psF64 clippedStdev;        ///< standard deviation after clipping
-    psS32 clippedNvalues;         ///< ???
+    psS32 clippedNvalues;      ///< Number of data points used for clipped mean:  This value is never used.
     psF64 clipSigma;           ///< Nsigma used for clipping; user input
-    psS32 clipIter;               ///< Number of clipping iterations; user input
+    psS32 clipIter;            ///< Number of clipping iterations; user input
     psF64 min;                 ///< minimum data value in array
     psF64 max;                 ///< maximum data value in array
-    psF64 binsize;             ///<
-    psStatsOptions options;     ///< bitmask of calculated values
+    psF64 binsize;             ///< binsize for robust fit (input/ouput)
+    psStatsOptions options;    ///< bitmask of calculated values
 }
 psStats;
@@ -86,9 +90,9 @@
  */
 psStats* psVectorStats(
-    psStats* stats,    ///< stats structure defines stats to be calculated and how
+    psStats* stats,          ///< stats structure defines stats to be calculated and how
     const psVector* in,      ///< Vector to be analysed.
     const psVector* errors,  ///< Errors.
     const psVector* mask,    ///< Ignore elements where (maskVector & maskVal) != 0: must be INT or NULL
-    psU32 maskVal      ///< Only mask elements with one of these bits set in maskVector
+    psU32 maskVal            ///< Only mask elements with one of these bits set in maskVector
 );
 
@@ -119,7 +123,7 @@
     psVector* bounds;                  ///< Bounds for the bins (type F32)
     psVector* nums;                    ///< Number in each of the bins (INT)
-    psS32 minNum;                        ///< Number below the minimum
-    psS32 maxNum;                        ///< Number above the maximum
-    psBool uniform;                      ///< Is it a uniform distribution?
+    psS32 minNum;                      ///< Number below the minimum
+    psS32 maxNum;                      ///< Number above the maximum
+    psBool uniform;                    ///< Is it a uniform distribution?
 }
 psHistogram;
@@ -134,5 +138,5 @@
     psF32 lower,                       ///< Lower limit for the bins
     psF32 upper,                       ///< Upper limit for the bins
-    psS32 n                              ///< Number of bins
+    psS32 n                            ///< Number of bins
 );
 
@@ -165,15 +169,15 @@
  *
  *  @return psBool    If more than one statistic result is set in stats->options,
- *                  false is returned and the value parameter is not set, 
- *                  otherwise true is returned.
+ *                    false is returned and the value parameter is not set, 
+ *                    otherwise true is returned.
  */
 psBool p_psGetStatValue(
-    const psStats* stats,
-    ///< the statistic struct to operate on
+    const psStats* stats, ///< the statistic struct to operate on
 
-    psF64 *value
-    ///< if return is true, this is set to the specified statistic value by stats->options
+    psF64 *value ///< if return is true, this is set to the specified statistic value by stats->options
 );
 
+// XXX: Create a single, generic, version of the vector normalize function.
+// XXX: Ask IfA for a public psLib function.
 void p_psNormalizeVectorRangeU8(psVector* myData, psU8 low, psU8 high);
 void p_psNormalizeVectorRangeU16(psVector* myData, psU16 low, psU16 high);
