Index: trunk/psLib/src/math/psStats.c
===================================================================
--- trunk/psLib/src/math/psStats.c	(revision 10384)
+++ trunk/psLib/src/math/psStats.c	(revision 10395)
@@ -16,6 +16,6 @@
  * use ->min and ->max (PS_STAT_USE_RANGE)
  *
- *  @version $Revision: 1.191 $ $Name: not supported by cvs2svn $
- *  @date $Date: 2006-11-29 17:55:25 $
+ *  @version $Revision: 1.192 $ $Name: not supported by cvs2svn $
+ *  @date $Date: 2006-12-01 22:41:33 $
  *
  *  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
@@ -1090,9 +1090,16 @@
     tmpScalar.type.type = PS_TYPE_F32;
 
-    // construct a histogram with (sigma/10 < binsize < sigma)
-    // set roughly so that the lowest bins have about 2 cnts
-    // Nsmallest ~ N50 / (4*dN))
-    psF32 dN = PS_MAX (1, PS_MIN (10, stats->robustN50 / 8));
-    psF32 newBinSize = stats->fittedStdev / dN;
+    psF32 binSize = 1;
+    if (stats->options & PS_STAT_USE_BINSIZE) {
+        // Set initial bin size to the specified value.
+        binSize = stats->binsize;
+        psTrace("psLib.math", 6, "Setting initial robust bin size to %.2f\n", binSize);
+    } else {
+        // construct a histogram with (sigma/10 < binsize < sigma)
+        // set roughly so that the lowest bins have about 2 cnts
+        // Nsmallest ~ N50 / (4*dN))
+        psF32 dN = PS_MAX (1, PS_MIN (10, stats->robustN50 / 8));
+        binSize = stats->fittedStdev / dN;
+    }
 
     // Determine the min/max of the vector (which prior outliers masked out)
@@ -1108,7 +1115,7 @@
 
     // Calculate the number of bins.
-    long numBins = (max - min) / newBinSize;
+    long numBins = (max - min) / binSize;
     psTrace("psLib.math", 6, "The new min/max values are (%f, %f).\n", min, max);
-    psTrace("psLib.math", 6, "The new bin size is %f.\n", newBinSize);
+    psTrace("psLib.math", 6, "The new bin size is %f.\n", binSize);
     psTrace("psLib.math", 6, "The numBins is %ld\n", numBins);
 
Index: trunk/psLib/test/math/tap_psStats_Sample_01.c
===================================================================
--- trunk/psLib/test/math/tap_psStats_Sample_01.c	(revision 10384)
+++ trunk/psLib/test/math/tap_psStats_Sample_01.c	(revision 10395)
@@ -226,10 +226,12 @@
         psMemId id = psMemGetId();
 
-        diag("sample 1");
+        diag("sample 1 : problem with integer-binned data driven to tiny sigma values");
         psStats *stats = psStatsAlloc (PS_STAT_FITTED_MEAN | PS_STAT_FITTED_STDEV |
                                        PS_STAT_ROBUST_MEDIAN | PS_STAT_ROBUST_STDEV |
                                        PS_STAT_CLIPPED_MEAN | PS_STAT_CLIPPED_STDEV |
                                        PS_STAT_SAMPLE_MEAN | PS_STAT_SAMPLE_MEDIAN |
-                                       PS_STAT_SAMPLE_STDEV);
+                                       PS_STAT_SAMPLE_STDEV | PS_STAT_USE_BINSIZE);
+        stats->binsize = 1.0;
+
 
         // copy data in static array
