Changeset 2251 for trunk/psLib/src/math/psStats.c
- Timestamp:
- Nov 1, 2004, 2:07:49 PM (22 years ago)
- File:
-
- 1 edited
-
trunk/psLib/src/math/psStats.c (modified) (7 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/psLib/src/math/psStats.c
r2250 r2251 9 9 * @author GLG, MHPCC 10 10 * 11 * @version $Revision: 1.8 1$ $Name: not supported by cvs2svn $12 * @date $Date: 2004-11-0 1 23:57:08$11 * @version $Revision: 1.82 $ $Name: not supported by cvs2svn $ 12 * @date $Date: 2004-11-02 00:07:49 $ 13 13 * 14 14 * Copyright 2004 Maui High Performance Computing Center, University of Hawaii … … 53 53 psVector* p_psConvertToF32(psVector* in); 54 54 55 voidp_psVectorRobustStats(const psVector* restrict myVector,56 const psVector* restrict maskVector,57 psU32 maskVal,58 psStats* stats);55 int p_psVectorRobustStats(const psVector* restrict myVector, 56 const psVector* restrict maskVector, 57 psU32 maskVal, 58 psStats* stats); 59 59 /*****************************************************************************/ 60 60 /* GLOBAL VARIABLES */ … … 1027 1027 NULL 1028 1028 *****************************************************************************/ 1029 voidp_psVectorRobustStats(const psVector* restrict myVector,1030 const psVector* restrict maskVector,1031 psU32 maskVal,1032 psStats* stats)1029 int p_psVectorRobustStats(const psVector* restrict myVector, 1030 const psVector* restrict maskVector, 1031 psU32 maskVal, 1032 psStats* stats) 1033 1033 { 1034 1034 psHistogram* robustHistogram = NULL; … … 1086 1086 stats->robustN50 = 0.0; 1087 1087 psFree(tmpStats); 1088 return ;1088 return(0); 1089 1089 } 1090 1090 // Determine minimum and maximum values in the data vector. … … 1138 1138 if ((LQBinNum < 0) || (UQBinNum < 0)) { 1139 1139 psError(__func__, "Could not determine the robust lower/upper quartile bin numbers."); 1140 return(1); 1140 1141 } 1141 1142 if (medianBinNum < 0) { 1142 1143 psError(__func__, "Could not determine the robust lower/upper quartile bin numbers."); 1144 return(1); 1143 1145 } 1144 1146 /************************************************************************** … … 1281 1283 psFree(robustHistogramVector); 1282 1284 psFree(cumulativeRobustSums); 1283 } 1284 1285 /* 1286 void p_ps_FitTheGaussian() 1287 { 1288 // Fit a Gaussian to the bins in the range MODE-dL to Mode+dL 1289 // NOTE: This code uses the psMinimize.c functions to perform 1290 // the fit. It doesn't quite work, 100% of the time. For the time being 1291 // I am commenting this code out, and replacing it with code which 1292 // calculates the mean directly on the robustHistogram. 1293 1294 domain = psImageAlloc(1, robustHistogramVector->n, PS_TYPE_F32); 1295 errors = psVectorAlloc(robustHistogramVector->n, PS_TYPE_F32); 1296 data = psVectorAlloc(robustHistogramVector->n, PS_TYPE_F32); 1297 initialGuess = psVectorAlloc(2, PS_TYPE_F32); 1298 1299 max = -HUGE; 1300 max_pos = -1; 1301 for (i=0;i<robustHistogramVector->n;i++) { 1302 domain->data.F32[i][0] = PS_BIN_MIDPOINT(robustHistogram, i);bounds->data.F32[modeBinNum + 1]); 1303 data->data.F32[i] = (float) robustHistogramVector->data.F32[i]; 1304 errors->data.F32[i] = 1.0; 1305 //printf("DATA (%.2f, %.2f)\n", domain->data.F32[i][0], data->data.F32[i]); 1306 if (data->data.F32[i] > max) { 1307 max = data->data.F32[i]; 1308 max_pos = domain->data.F32[i][0]; 1309 } 1310 } 1311 1312 initialGuess->data.F32[0] = max_pos; 1313 initialGuess->data.F32[1] = 1.0; 1314 printf("Initial (mean. stdev) is (%.3f, %.3f)\n", initialGuess->data.F32[0], initialGuess->data.F32[1]); 1315 1316 printf("Calling psMinimizeChi2()\n"); 1317 theParams = psMinimizeChi2(p_psGaussian, 1318 p_psGaussianDeriv, 1319 domain, 1320 data, 1321 errors, 1322 initialGuess, 1323 NULL, 1324 &chiSq); 1325 printf("Called psMinimizeChi2()\n"); 1326 printf("p_psVectorRobustStats() is (%f, %f)\n", theParams->data.F32[0], theParams->data.F32[1]); 1327 } 1328 */ 1285 return(0); 1286 } 1329 1287 1330 1288 /*****************************************************************************/ … … 1670 1628 (stats->options & PS_STAT_ROBUST_MODE) || 1671 1629 (stats->options & PS_STAT_ROBUST_STDEV) || (stats->options & PS_STAT_ROBUST_QUARTILE)) { 1672 p_psVectorRobustStats(inF32, mask, maskVal, stats); 1630 if (0 != p_psVectorRobustStats(inF32, mask, maskVal, stats)) { 1631 psError(__func__, "p_psVectorRobustStats() failed.\n"); 1632 } 1673 1633 } 1674 1634
Note:
See TracChangeset
for help on using the changeset viewer.
