Changeset 5113 for trunk/psLib/test/math/tst_psStats07.c
- Timestamp:
- Sep 23, 2005, 1:01:30 PM (21 years ago)
- File:
-
- 1 edited
-
trunk/psLib/test/math/tst_psStats07.c (modified) (15 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/psLib/test/math/tst_psStats07.c
r4861 r5113 34 34 float realMeanNoMask = MEAN; 35 35 float realMedianNoMask = MEAN; 36 float realModeNoMask = MEAN;37 float realStdevNoMask = STDEV * 0.20;36 // float realModeNoMask = MEAN; 37 float realStdevNoMask = STDEV; 38 38 float realLQNoMask = MEAN - ( 0.6 * STDEV ); 39 39 float realUQNoMask = MEAN + ( 0.6 * STDEV ); 40 40 psS32 realN50NoMask = N / 4; 41 41 psS32 realNfitNoMask = N / 4; 42 43 psTraceSetLevel(".psLib.dataManip", 0);44 42 45 43 /*************************************************************************/ … … 55 53 maskVector->n = N; 56 54 myVector = p_psGaussianDev( MEAN, STDEV, N ); 55 // Create a full outliers: 56 myVector->data.F32[N/4] = -1000.0 * MEAN; 57 myVector->data.F32[N/2] = 1000.0 * MEAN; 57 58 // Set the mask vector and calculate the expected maximum. 58 59 for ( i = 0;i < N;i++ ) { … … 72 73 73 74 myStats = psVectorStats( myStats, myVector, NULL, NULL, 0 ); 75 if (myStats == NULL) { 76 printf("TEST ERROR: psVectorStats() returned NULL.\n"); 77 return(false); 78 } 74 79 75 80 printf( "The expected Mean was %.2f; the calculated Mean was %.2f\n", … … 105 110 testStatus ); 106 111 107 printPositiveTestHeader( stdout,108 "psStats functions",109 "PS_STAT_ROBUST_STATS: robust Mode: no vector mask" );110 111 112 printf( "The expected Mode was %.2f; the calculated Mode was %.2f\n",113 realModeNoMask, myStats->robustMode );114 if ( fabs( myStats->robustMode - realModeNoMask ) < ( ERROR_TOLERANCE * realModeNoMask ) ) {115 testStatus = true;116 } else {117 testStatus = false;118 globalTestStatus = false;119 }120 printFooter( stdout,121 "psVector functions",122 "PS_STAT_ROBUST_STATS: robust Mode: no vector mask",123 testStatus );124 125 112 /* XXX: Should we test mode? 113 printPositiveTestHeader( stdout, 114 "psStats functions", 115 "PS_STAT_ROBUST_STATS: robust Mode: no vector mask" ); 116 117 118 printf( "The expected Mode was %.2f; the calculated Mode was %.2f\n", 119 realModeNoMask, myStats->robustMode ); 120 if ( fabs( myStats->robustMode - realModeNoMask ) < ( ERROR_TOLERANCE * realModeNoMask ) ) { 121 testStatus = true; 122 } else { 123 testStatus = false; 124 globalTestStatus = false; 125 } 126 printFooter( stdout, 127 "psVector functions", 128 "PS_STAT_ROBUST_STATS: robust Mode: no vector mask", 129 testStatus ); 130 */ 126 131 127 132 printPositiveTestHeader( stdout, … … 143 148 144 149 145 146 150 printPositiveTestHeader( stdout, 147 151 "psStats functions", … … 161 165 "PS_STAT_ROBUST_STATS: lower quartile: no vector mask", 162 166 testStatus ); 163 164 165 167 166 168 printPositiveTestHeader( stdout, … … 180 182 "PS_STAT_ROBUST_STATS: lower quartile: no vector mask", 181 183 testStatus ); 182 183 184 184 185 185 printPositiveTestHeader( stdout, … … 205 205 testStatus ); 206 206 207 208 209 207 printPositiveTestHeader( stdout, 210 208 "psStats functions", … … 228 226 "PS_STAT_ROBUST_STATS: robust Nfit: no vector mask", 229 227 testStatus ); 230 return(testStatus);231 228 232 229 /*************************************************************************/ … … 252 249 testStatus ); 253 250 254 if (globalTestStatus == false) 255 printf("Returning FALSE\n"); 256 else 257 printf("Returning TRUE\n"); 258 return ( !globalTestStatus ); 251 return ( globalTestStatus ); 259 252 } 260 253 … … 276 269 float realMeanWithMask = MEAN; 277 270 float realMedianWithMask = MEAN; 278 float realModeWithMask = MEAN;279 float realStdevWithMask = STDEV * 0.20;271 // float realModeWithMask = MEAN; 272 float realStdevWithMask = STDEV; 280 273 float realLQWithMask = MEAN; 281 274 float realUQWithMask = MEAN; 282 275 psS32 realN50WithMask = N / 4; 283 276 psS32 realNfitWithMask = N / 4; 284 285 psTraceSetLevel(".psLib.dataManip.psStats", 0);286 287 277 /*************************************************************************/ 288 278 /* Allocate and initialize data structures */ … … 316 306 printf( "Calling psVectorStats() on a vector with elements masked.\n" ); 317 307 myStats = psVectorStats( myStats, myVector, NULL, maskVector, 1 ); 308 if (myStats == NULL) { 309 printf("TEST ERROR: psVectorStats() returned NULL.\n"); 310 return(false); 311 } 318 312 printf( "Called psVectorStats() on a vector with elements masked.\n" ); 319 313 printf( "The expected Mean was %.2f; the calculated Mean was %.2f\n", … … 348 342 349 343 350 351 printPositiveTestHeader( stdout,352 "psStats functions",353 "PS_STAT_ROBUST_STATS: robust Mode: with vector mask" );354 355 printf( "The expected Mode was %.2f; the calculated Mode was %.2f\n",356 realModeWithMask, myStats->robustMode );357 if ( fabs( myStats->robustMode - realModeWithMask ) < ( ERROR_TOLERANCE * realModeWithMask ) ) {358 testStatus = true;359 } else {360 testStatus = false;361 globalTestStatus = false;362 }363 printFooter( stdout,364 "psVector functions",365 "PS_STAT_ROBUST_STATS: robust Mode: with vector mask",366 testStatus );367 344 /* XXX: mode is not set? 345 printPositiveTestHeader( stdout, 346 "psStats functions", 347 "PS_STAT_ROBUST_STATS: robust Mode: with vector mask" ); 348 349 printf( "The expected Mode was %.2f; the calculated Mode was %.2f\n", 350 realModeWithMask, myStats->robustMode ); 351 if ( fabs( myStats->robustMode - realModeWithMask ) < ( ERROR_TOLERANCE * realModeWithMask ) ) { 352 testStatus = true; 353 } else { 354 testStatus = false; 355 globalTestStatus = false; 356 } 357 printFooter( stdout, 358 "psVector functions", 359 "PS_STAT_ROBUST_STATS: robust Mode: with vector mask", 360 testStatus ); 361 */ 368 362 369 363 … … 489 483 testStatus ); 490 484 491 if (globalTestStatus == false) 492 printf("Returning FALSE\n"); 493 else 494 printf("Returning TRUE\n"); 495 496 return ( !globalTestStatus ); 485 return ( globalTestStatus ); 497 486 } 498 487 … … 500 489 { 501 490 psLogSetFormat("HLNM"); 502 psBool rc = t00(); 503 rc |= t01(); 504 505 return(rc); 491 psTraceSetLevel(".", 0); 492 psTraceSetLevel("psGaussian", 0); 493 psBool rc0 = t00(); 494 psBool rc1 = t01(); 495 496 return(rc0 & rc1); 506 497 }
Note:
See TracChangeset
for help on using the changeset viewer.
