Index: trunk/psLib/src/math/psStats.c
===================================================================
--- trunk/psLib/src/math/psStats.c	(revision 31152)
+++ trunk/psLib/src/math/psStats.c	(revision 34703)
@@ -764,4 +764,8 @@
             goto escape;
         }
+        if (!isfinite(max - min)) {
+            COUNT_WARNING(10, 100, "Range of of the input vector is too large: %lf.\n", (double)max - (double) min);
+            goto escape;
+        }
         psTrace(TRACE, 6, "Data min/max is (%.2f, %.2f)\n", min, max);
 
@@ -802,4 +806,9 @@
         psTrace(TRACE, 6, "Numbins is %ld\n", numBins);
         psTrace(TRACE, 6, "Creating a robust histogram from data range (%.2f - %.2f)\n", min, max);
+
+        // We are sometimes causing psHistogramAlloc to assert.
+        // Assert here so we can get more information about what is going wrong.
+        psAssert(numBins > 0, "Invalid numBins: %ld max: %f min: %f binSize: %f", numBins, max, min, binSize);
+        
         // Generate the histogram
         histogram = psHistogramAlloc(min - 2.0*binSize, max + 2.0*binSize, numBins);
@@ -858,4 +867,8 @@
             // if we did not mask anything, give up.
         }
+
+        // We were causing psHistogramAlloc to assert. 
+        // Assert here so we can get more information about what is going wrong.
+        psAssert(numBins > 0, "Invalid numBins %ld max: %f min: %f binSize: %f", numBins, max, min, binSize);
 
         // ADD step 1: Convert the specific histogram to a cumulative histogram
