Index: trunk/psLib/src/math/psStats.c
===================================================================
--- trunk/psLib/src/math/psStats.c	(revision 2250)
+++ trunk/psLib/src/math/psStats.c	(revision 2251)
@@ -9,6 +9,6 @@
  *  @author GLG, MHPCC
  *
- *  @version $Revision: 1.81 $ $Name: not supported by cvs2svn $
- *  @date $Date: 2004-11-01 23:57:08 $
+ *  @version $Revision: 1.82 $ $Name: not supported by cvs2svn $
+ *  @date $Date: 2004-11-02 00:07:49 $
  *
  *  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
@@ -53,8 +53,8 @@
 psVector* p_psConvertToF32(psVector* in);
 
-void p_psVectorRobustStats(const psVector* restrict myVector,
-                           const psVector* restrict maskVector,
-                           psU32 maskVal,
-                           psStats* stats);
+int p_psVectorRobustStats(const psVector* restrict myVector,
+                          const psVector* restrict maskVector,
+                          psU32 maskVal,
+                          psStats* stats);
 /*****************************************************************************/
 /* GLOBAL VARIABLES                                                          */
@@ -1027,8 +1027,8 @@
     NULL
 *****************************************************************************/
-void p_psVectorRobustStats(const psVector* restrict myVector,
-                           const psVector* restrict maskVector,
-                           psU32 maskVal,
-                           psStats* stats)
+int p_psVectorRobustStats(const psVector* restrict myVector,
+                          const psVector* restrict maskVector,
+                          psU32 maskVal,
+                          psStats* stats)
 {
     psHistogram* robustHistogram = NULL;
@@ -1086,5 +1086,5 @@
         stats->robustN50 = 0.0;
         psFree(tmpStats);
-        return;
+        return(0);
     }
     // Determine minimum and maximum values in the data vector.
@@ -1138,7 +1138,9 @@
     if ((LQBinNum < 0) || (UQBinNum < 0)) {
         psError(__func__, "Could not determine the robust lower/upper quartile bin numbers.");
+        return(1);
     }
     if (medianBinNum < 0) {
         psError(__func__, "Could not determine the robust lower/upper quartile bin numbers.");
+        return(1);
     }
     /**************************************************************************
@@ -1281,50 +1283,6 @@
     psFree(robustHistogramVector);
     psFree(cumulativeRobustSums);
-}
-
-/*
-void p_ps_FitTheGaussian()
-{
-    // Fit a Gaussian to the bins in the range MODE-dL to Mode+dL
-    // NOTE: This code uses the psMinimize.c functions to perform
-    // the fit.  It doesn't quite work, 100% of the time.  For the time being
-    // I am commenting this code out, and replacing it with code which
-    // calculates the mean directly on the robustHistogram.
- 
-    domain = psImageAlloc(1, robustHistogramVector->n, PS_TYPE_F32);
-    errors = psVectorAlloc(robustHistogramVector->n, PS_TYPE_F32);
-    data = psVectorAlloc(robustHistogramVector->n, PS_TYPE_F32);
-    initialGuess = psVectorAlloc(2, PS_TYPE_F32);
- 
-    max = -HUGE;
-    max_pos = -1;
-    for (i=0;i<robustHistogramVector->n;i++) {
-        domain->data.F32[i][0] =  PS_BIN_MIDPOINT(robustHistogram, i);bounds->data.F32[modeBinNum + 1]);
-        data->data.F32[i] = (float) robustHistogramVector->data.F32[i];
-        errors->data.F32[i] = 1.0;
-        //printf("DATA (%.2f, %.2f)\n", domain->data.F32[i][0], data->data.F32[i]);
-        if (data->data.F32[i] > max) {
-            max = data->data.F32[i];
-            max_pos = domain->data.F32[i][0];
-        }
-    }
- 
-    initialGuess->data.F32[0] = max_pos;
-    initialGuess->data.F32[1] = 1.0;
-    printf("Initial (mean. stdev) is (%.3f, %.3f)\n", initialGuess->data.F32[0], initialGuess->data.F32[1]);
- 
-    printf("Calling psMinimizeChi2()\n");
-    theParams = psMinimizeChi2(p_psGaussian,
-                               p_psGaussianDeriv,
-                               domain,
-                               data,
-                               errors,
-                               initialGuess,
-                               NULL,
-                               &chiSq);
-    printf("Called psMinimizeChi2()\n");
-    printf("p_psVectorRobustStats() is (%f, %f)\n", theParams->data.F32[0], theParams->data.F32[1]);
-}
-*/
+    return(0);
+}
 
 /*****************************************************************************/
@@ -1670,5 +1628,7 @@
             (stats->options & PS_STAT_ROBUST_MODE) ||
             (stats->options & PS_STAT_ROBUST_STDEV) || (stats->options & PS_STAT_ROBUST_QUARTILE)) {
-        p_psVectorRobustStats(inF32, mask, maskVal, stats);
+        if (0 != p_psVectorRobustStats(inF32, mask, maskVal, stats)) {
+            psError(__func__, "p_psVectorRobustStats() failed.\n");
+        }
     }
 
