Index: trunk/psLib/src/dataManip/psStats.h
===================================================================
--- trunk/psLib/src/dataManip/psStats.h	(revision 729)
+++ trunk/psLib/src/dataManip/psStats.h	(revision 796)
@@ -1,5 +1,7 @@
 #if !defined(PS_STATS_H)
 #define PS_STATS_H
-
+/******************************************************************************
+    This file will histogram/statistical functions and data structures.
+ *****************************************************************************/
 /** \file psStats.h
  *  \brief basic statistical operations
@@ -7,28 +9,24 @@
  */
 #include "psVector.h"
-
-/** statistics which may be calculated */
+/******************************************************************************
+    Statistical functions and data structures.
+ *****************************************************************************/
 typedef enum {
     PS_STAT_SAMPLE_MEAN           = 0x000001,
     PS_STAT_SAMPLE_MEDIAN         = 0x000002,
     PS_STAT_SAMPLE_STDEV          = 0x000004,
-    PS_STAT_SAMPLE_UQ             = 0x000008,
-    PS_STAT_SAMPLE_LQ             = 0x000010,
-    PS_STAT_ROBUST_MEAN           = 0x000020,
-    PS_STAT_ROBUST_MEAN_NVALUES   = 0x000040,
-    PS_STAT_ROBUST_MEDIAN         = 0x000080,
-    PS_STAT_ROBUST_MEDIAN_NVALUES = 0x000100,
-    PS_STAT_ROBUST_MODE           = 0x000200,
-    PS_STAT_ROBUST_MODE_NVALUES   = 0x000400,
-    PS_STAT_ROBUST_STDEV          = 0x000800,
-    PS_STAT_ROBUST_UQ             = 0x001000,
-    PS_STAT_ROBUST_LQ             = 0x002000,
-    PS_STAT_CLIPPED_MEAN          = 0x004000,
-    PS_STAT_CLIPPED_MEAN_NVALUES  = 0x008000,
-    PS_STAT_CLIPPED_MEAN_NSIGMA   = 0x010000,
-    PS_STAT_CLIPPED_STDEV         = 0x020000,
-    PS_STAT_MAX                   = 0x040000,
-    PS_STAT_MIN                   = 0x080000,
-    PS_STAT_NVALUES               = 0x100000
+    PS_STAT_SAMPLE_QUARTILE       = 0x000008,
+    PS_STAT_ROBUST_MEAN           = 0x000010,
+    PS_STAT_ROBUST_MEDIAN         = 0x000020,
+    PS_STAT_ROBUST_MODE           = 0x000040,
+    PS_STAT_ROBUST_STDEV          = 0x000080,
+    PS_STAT_ROBUST_QUARTILE       = 0x000100,
+    PS_STAT_CLIPPED_MEAN          = 0x000200,
+    PS_STAT_CLIPPED_STDEV         = 0x000400,
+    PS_STAT_MAX                   = 0x000800,
+    PS_STAT_MIN                   = 0x001000,
+    PS_STAT_USE_RANGE             = 0x002000,
+    PS_STAT_USE_BINSIZE           = 0x004000,
+    PS_STAT_ROBUST_FOR_SAMPLE     = 0x008000
 } psStatsOptions;
 
@@ -42,15 +40,15 @@
     double sampleUQ;            ///< upper quartile of sample
     double sampleLQ;            ///< lower quartile of sample
+    double sampleLimit;         ///<
     double robustMean;          ///< robust mean of array
     int    robustMeanNvalues;   ///< number of measurements used for robust mean
     double robustMedian;        ///< robust median of array
-    int    robustMedianNvalues; ///< number of measurements used for robust median
     double robustMode;          ///< Robust mode of array
-    int    robustModeNvalues;   ///< Number of measurements used for robust mode
     double robustStdev;         ///< robust standard deviation of array
     double robustUQ;            ///< robust upper quartile
     double robustLQ;            ///< robust lower quartile
+    double robustN50;           ///<
+    double robustNfit;          ///<
     double clippedMean;         ///< Nsigma clipped mean
-    int    clippedMeanNvalues;  ///< number of data points used for clipped mean
     double clippedStdev;        ///< standard deviation after clipping
     double clipSigma;           ///< Nsigma used for clipping; user input
@@ -58,5 +56,5 @@
     double min;                 ///< minimum data value in array
     double max;                 ///< maximum data value in array
-    int    nValues;             ///< number of data values in array
+    double binsize;             ///<
     psStatsOptions options;     ///< bitmask of calculated values
 }
@@ -66,34 +64,29 @@
 /** Do Statistics on an array.  Returns a status value. \ingroup MathGroup */
 psStats *
-psArrayStats(const psVector *restrict myVector, ///< Vector to be analysed: must be FLOAT
-             const psVector *restrict maskVector, ///< Ignore elements where (maskVector & maskVal) != 0: must be INT or NULL
-             unsigned int maskVal, ///< Only mask elements with one of these bits set in maskVector
-             psStats *stats  ///< stats structure defines stats to be calculated and how
-            );
+psVectorStats(psStats *stats,       ///< stats structure defines stats to be calculated and how
+              psVector *in,         ///< Vector to be analysed: must be F32
+              psVector *mask,       ///< Ignore elements where (maskVector & maskVal) != 0: must be INT or NULL
+              unsigned int maskVal ///< Only mask elements with one of these bits set in maskVector
+             );
 
 /** Constructor */
-psStats *
-psStatsAlloc(psStatsOptions options ///< Statistics to measure
-            );
+psStats *psStatsAlloc(psStatsOptions options); ///< Statistics to measure
 
 /** Destructor */
-void
-psStatsFree(psStats *restrict stats ///< Stats structure to destroy
-           );
+void psStatsFree(psStats *restrict stats); ///< Stats structure to destroy
 
-/** Histograms  */
-// NOTE: I added the numBins member.  Must consult with IfA on this.
+/******************************************************************************
+    Histogram functions and data structures.
+ *****************************************************************************/
 typedef struct
 {
-    const psVector *restrict lower; ///< Lower bounds for the bins (FLOAT)
-    const psVector *restrict upper; ///< Upper bounds for the bins (FLOAT)
-    psVector *nums;                 ///< Number in each of the bins (INT)
-    float minVal;
-    float maxVal;                   ///< Minimum and maximum values
-    int minNum;
-    int maxNum;                     ///< Number below the minimum and above the maximum
-    int numBins;                    ///< Number of bins in this histogram.
+    const psVector *restrict bounds; ///< Bounds for the bins (type F32)
+    psVector *nums;                  ///< Number in each of the bins (INT)
+    int minNum;                      ///< Number below the minimum
+    int maxNum;                      ///< Number above the maximum
+    int uniform;                     ///< Is it a uniform distribution?
 }
 psHistogram;
+
 
 /** Constructor \ingroup MathGroup */
@@ -101,26 +94,21 @@
 psHistogramAlloc(float lower,  ///< Lower limit for the bins
                  float upper,  ///< Upper limit for the bins
-                 float size    ///< Size of the bins
-                );
+                 int n);       ///< Number of bins
+
 
 /** Generic constructor \ingroup MathGroup */
-psHistogram *
-psHistogramAllocGeneric(const psVector *restrict lower, ///< Lower bounds for the bins
-                        const psVector *restrict upper, ///< Upper bounds for the bins
-                        float minVal,                   ///< Minimum value
-                        float maxVal                    ///< Maximum value
-                       );
+psHistogram * psHistogramAllocGeneric(const psVector *restrict bounds); ///< Bounds for the bins
+
 
 /** Destructor \ingroup MathGroup **/
-void
-psHistogramFree(psHistogram *restrict myHist          ///< Histogram to destroy
-               );
+void psHistogramFree(psHistogram *restrict myHist);          ///< Histogram to destroy
 
 
 /** Calculate a histogram \ingroup MathGroup **/
-psHistogram *
-psGetArrayHistogram(psHistogram *restrict myHist,     ///< Histogram data
-                    const psVector *restrict myVector ///< Vector to analyse
-                   );
+psHistogram *psHistogramVector (psHistogram *out,   ///< Histogram data
+                                psVector *in,       ///< Vector to analyse
+                                psVector *mask,     ///< Mask dat for input vector
+                                int maskVal);       ///< Mask value
+
 
 #endif
