Index: trunk/psLib/src/math/psStats.h
===================================================================
--- trunk/psLib/src/math/psStats.h	(revision 8468)
+++ trunk/psLib/src/math/psStats.h	(revision 10550)
@@ -7,20 +7,16 @@
  *  on those data structures.
  *
- *  XXX: The following stats members are never used, or set in this code.
- *      stats->robustN50
- *      stats->clippedNvalues
- *      stats->binsize
- *
  *  @author GLG, MHPCC
  *
- *  @version $Revision: 1.56 $ $Name: not supported by cvs2svn $
- *  @date $Date: 2006-08-22 15:02:08 $
+ *  @version $Revision: 1.57 $ $Name: not supported by cvs2svn $
+ *  @date $Date: 2006-12-08 11:38:54 $
  *
  *  Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii
  */
+
 #ifndef PS_STATS_H
 #define PS_STATS_H
 
-#include "psVector.h"
+// #include "psVector.h"
 
 /// @addtogroup Stats
@@ -35,6 +31,6 @@
  *  @see psStats, psVectorStats, psImageStats
  */
-// XXX: Is PS_STAT_ROBUST_FOR_SAMPLE obsolete?
 typedef enum {
+    PS_STAT_NONE            = 0x000000, ///< Empty set
     PS_STAT_SAMPLE_MEAN     = 0x000001, ///< Sample Mean
     PS_STAT_SAMPLE_MEDIAN   = 0x000002, ///< Sample Median
@@ -51,5 +47,7 @@
     PS_STAT_MIN             = 0x001000, ///< Minumum
     PS_STAT_USE_RANGE       = 0x002000, ///< Range
-    PS_STAT_USE_BINSIZE     = 0x004000  ///< Binsize
+    PS_STAT_USE_BINSIZE     = 0x004000, ///< Binsize
+    PS_STAT_FITTED_MEAN_V2  = 0x008000, ///< Fitted Mean
+    PS_STAT_FITTED_STDEV_V2 = 0x010000, ///< Fitted Standard Deviation
 } psStatsOptions;
 
@@ -81,5 +79,6 @@
     double binsize;                    ///< binsize for robust fit (input/ouput)
     long nSubsample;                   ///< maxinum number of measurements (input)
-    psStatsOptions options;            ///< bitmask of calculated values
+    psStatsOptions options;            ///< bitmask of values requested
+    psStatsOptions results;            ///< bitmask of values calculated
 }
 psStats;
@@ -89,5 +88,5 @@
  *  @return psStats*    the statistical results as specified by stats->options
  */
-psStats* psVectorStats(
+bool psVectorStats(
     psStats* stats,                    ///< stats structure defines stats to be calculated and how
     const psVector* in,                ///< Vector to be analysed.
@@ -117,78 +116,4 @@
 );
 
-
-/******************************************************************************
-    Histogram functions and data structures.
- *****************************************************************************/
-
-/** The basic histogram structure which contains bounds and bins.
- *
- *  In this structure, the vector bounds specifies the boundaries of the
- *  histogram bins, and must of type psF32, while nums specifies the number
- *  of entries in the bin, and must of type psU32. The value of bounds.n must
- *  therefore be 1 greater than than nums.n. The two values minNum and maxNum
- *  are the number of data values which fell below the lower limit bound or
- *  above the upper limit bound, respectively.
- */
-typedef struct
-{
-    const psVector* 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
-    bool uniform;                      ///< Is it a uniform distribution?
-}
-psHistogram;
-
-/** Allocator for psHistogram where the bounds of the bins are implicitly
- *  specified through simply specifying an upper and lower limit along with
- *  the size of the bins.
- *
- *  @return psHistogram*    Newly allocated psHistogram
- */
-psHistogram* psHistogramAlloc(
-    float lower,                       ///< Lower limit for the bins
-    float upper,                       ///< Upper limit for the bins
-    int n                              ///< Number of bins
-);
-
-
-/** Checks the type of a particular pointer.
- *
- *  Uses the appropriate deallocation function in psMemBlock to check the ptr datatype.
- *
- *  @return bool:       True if the pointer matches a psHistogram structure, false otherwise.
- */
-bool psMemCheckHistogram(
-    psPtr ptr                          ///< the pointer whose type to check
-);
-
-
-/** Allocator for psHistogram where the bounds of the bins are explicitly
- *  specified.
- *
- *  @return psHistogram*    Newly allocated psHistogram
- */
-psHistogram* psHistogramAllocGeneric(
-    const psVector* bounds             ///< Bounds for the bins
-);
-
-/** Calculate a histogram
- *
- *  The following function populates the histogram bins from the specified
- *  vector (in). It alters and returns the histogram out structure. The input
- *  vector may be of types psU8, psU16, psF32, psF64.
- *
- *  @return psHistogram*   histogram result
- */
-psHistogram* psVectorHistogram(
-    psHistogram* out,                  ///< Histogram data
-    const psVector* values,            ///< Vector to analyse
-    const psVector* errors,            ///< Errors
-    const psVector* mask,              ///< Mask dat for input vector
-    psMaskType maskVal                 ///< Mask value
-);
-
-
 // Get the statistics option from a string
 psStatsOptions psStatsOptionFromString(const char *string);
@@ -207,2 +132,31 @@
 
 #endif // #ifndef PS_STATS_H
+
+/*
+ * private stats functions used in psStats.c:
+ *
+ * vectorSampleMean
+   (none)
+ * vectorMinMax
+   (none)
+ * vectorSampleMedian (also yields SAMPLE_QUARTILE)
+   (none) 
+ * vectorSampleStdev
+   (vectorSampleMean)
+ * vectorClippedStats
+   (vectorSampleMedian)
+   (vectorSampleMean (*also subset))
+   (vectorSampleStdev (*also subset))
+ * vectorRobustStats
+   (vectorMinMax (*only subset))
+ * vectorFittedStats
+   (vectorRobustStats)
+ 
+ * private stats functions called by other private stats functions are automatically called by
+ * those functions.  since they set the stats->results flags, they are not called multiple
+ * times.
+ 
+ * the private stats functions do not test for their corresponding stats flags: it is not
+ * necessary to request them if they are called within this function.
+ 
+*/
