00001 /** @file psStats.h 00002 * \brief basic statistical operations 00003 * @ingroup Stats 00004 * 00005 * This file will hold the definition of the histogram and stats data 00006 * structures. It also contains prototypes for procedures which operate 00007 * on those data structures. 00008 * 00009 * XXX: The following stats members are never used, or set in this code. 00010 * stats->robustN50 00011 * stats->clippedNvalues 00012 * stats->binsize 00013 * 00014 * @author GLG, MHPCC 00015 * 00016 * @version $Revision: 1.1.1.1 $ $Name: $ 00017 * @date $Date: 2005/06/15 21:08:12 $ 00018 * 00019 * Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii 00020 */ 00021 #ifndef PS_STATS_H 00022 #define PS_STATS_H 00023 00024 #include "psVector.h" 00025 00026 /// @addtogroup Stats 00027 /// @{ 00028 00029 /****************************************************************************** 00030 Statistical functions and data structures. 00031 *****************************************************************************/ 00032 00033 /** enumeration of statistical calculation options 00034 * 00035 * @see psStats, psVectorStats, psImageStats 00036 */ 00037 // XXX: Is PS_STAT_ROBUST_FOR_SAMPLE obsolete? 00038 typedef enum { 00039 PS_STAT_SAMPLE_MEAN = 0x000001, 00040 PS_STAT_SAMPLE_MEDIAN = 0x000002, 00041 PS_STAT_SAMPLE_STDEV = 0x000004, 00042 PS_STAT_SAMPLE_QUARTILE = 0x000008, 00043 PS_STAT_ROBUST_MEAN = 0x000010, 00044 PS_STAT_ROBUST_MEDIAN = 0x000020, 00045 PS_STAT_ROBUST_MODE = 0x000040, 00046 PS_STAT_ROBUST_STDEV = 0x000080, 00047 PS_STAT_ROBUST_QUARTILE = 0x000100, 00048 PS_STAT_CLIPPED_MEAN = 0x000200, 00049 PS_STAT_CLIPPED_STDEV = 0x000400, 00050 PS_STAT_MAX = 0x000800, 00051 PS_STAT_MIN = 0x001000, 00052 PS_STAT_USE_RANGE = 0x002000, 00053 PS_STAT_USE_BINSIZE = 0x004000, 00054 PS_STAT_ROBUST_FOR_SAMPLE = 0x008000 00055 } psStatsOptions; 00056 00057 /** This is the generic statistics structure. It contails the data members 00058 for the various statistic values. It also contains the options member to 00059 specifiy which statistics should be calculated. */ 00060 typedef struct 00061 { 00062 psF64 sampleMean; ///< formal mean of sample 00063 psF64 sampleMedian; ///< formal median of sample 00064 psF64 sampleStdev; ///< standard deviation of sample 00065 psF64 sampleUQ; ///< upper quartile of sample 00066 psF64 sampleLQ; ///< lower quartile of sample 00067 psF64 robustMean; ///< robust mean of array 00068 psF64 robustMedian; ///< robust median of array 00069 psF64 robustMode; ///< Robust mode of array 00070 psF64 robustStdev; ///< robust standard deviation of array 00071 psF64 robustUQ; ///< robust upper quartile 00072 psF64 robustLQ; ///< robust lower quartile 00073 psS32 robustN50; ///< Number of points in Gaussian fit. XXX: This is currently never set. 00074 psS32 robustNfit; ///< The number of points between the quartiles. 00075 psF64 clippedMean; ///< Nsigma clipped mean 00076 psF64 clippedStdev; ///< standard deviation after clipping 00077 psS32 clippedNvalues; ///< Number of data points used for clipped mean: This value is never used. 00078 psF64 clipSigma; ///< Nsigma used for clipping; user input 00079 psS32 clipIter; ///< Number of clipping iterations; user input 00080 psF64 min; ///< minimum data value in array 00081 psF64 max; ///< maximum data value in array 00082 psF64 binsize; ///< binsize for robust fit (input/ouput) 00083 psStatsOptions options; ///< bitmask of calculated values 00084 } 00085 psStats; 00086 00087 /** Performs statistical calculations on a vector. 00088 * 00089 * @return psStats* the statistical results as specified by stats->options 00090 */ 00091 psStats* psVectorStats( 00092 psStats* stats, ///< stats structure defines stats to be calculated and how 00093 const psVector* in, ///< Vector to be analysed. 00094 const psVector* errors, ///< Errors. 00095 const psVector* mask, ///< Ignore elements where (maskVector & maskVal) != 0: must be INT or NULL 00096 psU32 maskVal ///< Only mask elements with one of these bits set in maskVector 00097 ); 00098 00099 /** Allocator of the psStats structure. 00100 * 00101 * @return psStats* A new psStats struct with the options member set to the 00102 * value given. 00103 */ 00104 psStats* psStatsAlloc( 00105 psStatsOptions options ///< Statistics to calculate 00106 ); 00107 00108 /****************************************************************************** 00109 Histogram functions and data structures. 00110 *****************************************************************************/ 00111 00112 /** The basic histogram structure which contains bounds and bins. 00113 * 00114 * In this structure, the vector bounds specifies the boundaries of the 00115 * histogram bins, and must of type psF32, while nums specifies the number 00116 * of entries in the bin, and must of type psU32. The value of bounds.n must 00117 * therefore be 1 greater than than nums.n. The two values minNum and maxNum 00118 * are the number of data values which fell below the lower limit bound or 00119 * above the upper limit bound, respectively. 00120 */ 00121 typedef struct 00122 { 00123 psVector* bounds; ///< Bounds for the bins (type F32) 00124 psVector* nums; ///< Number in each of the bins (INT) 00125 psS32 minNum; ///< Number below the minimum 00126 psS32 maxNum; ///< Number above the maximum 00127 psBool uniform; ///< Is it a uniform distribution? 00128 } 00129 psHistogram; 00130 00131 /** Allocator for psHistogram where the bounds of the bins are implicitly 00132 * specified through simply specifying an upper and lower limit along with 00133 * the size of the bins. 00134 * 00135 * @return psHistogram* Newly allocated psHistogram 00136 */ 00137 psHistogram* psHistogramAlloc( 00138 psF32 lower, ///< Lower limit for the bins 00139 psF32 upper, ///< Upper limit for the bins 00140 psS32 n ///< Number of bins 00141 ); 00142 00143 /** Allocator for psHistogram where the bounds of the bins are explicitly 00144 * specified. 00145 * 00146 * @return psHistogram* Newly allocated psHistogram 00147 */ 00148 psHistogram* psHistogramAllocGeneric( 00149 const psVector* bounds ///< Bounds for the bins 00150 ); 00151 00152 /** Calculate a histogram 00153 * 00154 * The following function populates the histogram bins from the specified 00155 * vector (in). It alters and returns the histogram out structure. The input 00156 * vector may be of types psU8, psU16, psF32, psF64. 00157 * 00158 * @return psHistogram* histogram result 00159 */ 00160 psHistogram* psVectorHistogram( 00161 psHistogram* out, ///< Histogram data 00162 const psVector* in, ///< Vector to analyse 00163 const psVector* errors, ///< Errors 00164 const psVector* mask, ///< Mask dat for input vector 00165 psU32 maskVal ///< Mask value 00166 ); 00167 00168 /** Extracts the statistic value specified by stats->options. 00169 * 00170 * @return psBool If more than one statistic result is set in stats->options, 00171 * false is returned and the value parameter is not set, 00172 * otherwise true is returned. 00173 */ 00174 psBool p_psGetStatValue( 00175 const psStats* stats, ///< the statistic struct to operate on 00176 00177 psF64 *value ///< if return is true, this is set to the specified statistic value by stats->options 00178 ); 00179 00180 // XXX: Create a single, generic, version of the vector normalize function. 00181 // XXX: Ask IfA for a public psLib function. 00182 void p_psNormalizeVectorRangeU8(psVector* myData, psU8 low, psU8 high); 00183 void p_psNormalizeVectorRangeU16(psVector* myData, psU16 low, psU16 high); 00184 void p_psNormalizeVectorRangeU32(psVector* myData, psU32 low, psU32 high); 00185 void p_psNormalizeVectorRangeU64(psVector* myData, psU64 low, psU64 high); 00186 void p_psNormalizeVectorRangeS8(psVector* myData, psS8 low, psS8 high); 00187 void p_psNormalizeVectorRangeS16(psVector* myData, psS16 low, psS16 high); 00188 void p_psNormalizeVectorRangeS32(psVector* myData, psS32 low, psS32 high); 00189 void p_psNormalizeVectorRangeS64(psVector* myData, psS64 low, psS64 high); 00190 void p_psNormalizeVectorRangeF32(psVector* myData, psF32 low, psF32 high); 00191 void p_psNormalizeVectorRangeF64(psVector* myData, psF64 low, psF64 high); 00192 00193 /// @} 00194 00195 #endif // #ifndef PS_STATS_H
1.4.1