Changeset 5155 for trunk/psLib/test/math/tst_psStats07.c
- Timestamp:
- Sep 27, 2005, 1:19:47 PM (21 years ago)
- File:
-
- 1 edited
-
trunk/psLib/test/math/tst_psStats07.c (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/psLib/test/math/tst_psStats07.c
r5117 r5155 44 44 /* Allocate and initialize data structures */ 45 45 /*************************************************************************/ 46 maskVector = psVectorAlloc( N, PS_TYPE_U8 ); 47 maskVector->n = N; 48 myVector = p_psGaussianDev( MEAN, STDEV, N ); 49 // Set the mask vector and calculate the expected maximum. 50 for ( i = 0;i < N;i++ ) { 51 if ( i < ( N / 2 ) ) { 52 maskVector->data.U8[ i ] = 0; 53 count++; 54 } else { 55 maskVector->data.U8[ i ] = 1; 56 } 57 } 58 psStats *mySampleStats = psStatsAlloc( PS_STAT_SAMPLE_MEAN | 59 PS_STAT_SAMPLE_MEDIAN | 60 PS_STAT_SAMPLE_STDEV | 61 PS_STAT_SAMPLE_QUARTILE ); 62 mySampleStats = psVectorStats( mySampleStats, myVector, NULL, NULL, 0 ); 63 printf("The Sample Mean is %.2f\n", mySampleStats->sampleMean); 64 printf("The Sample Median is %.2f\n", mySampleStats->sampleMedian); 65 printf("The Sample stdev is %.2f\n", mySampleStats->sampleStdev); 66 printf("The Sample quartiles are (%.2f %.2f)\n", mySampleStats->sampleLQ, mySampleStats->sampleUQ); 67 psFree(mySampleStats); 68 69 psStats *mySampleStatsWithMask = psStatsAlloc( PS_STAT_SAMPLE_MEAN | 70 PS_STAT_SAMPLE_MEDIAN | 71 PS_STAT_SAMPLE_STDEV | 72 PS_STAT_SAMPLE_QUARTILE ); 73 mySampleStatsWithMask = psVectorStats( mySampleStatsWithMask, myVector, NULL, maskVector, 1 ); 74 printf("The Sample Mean is %.2f\n", mySampleStatsWithMask->sampleMean); 75 printf("The Sample Median is %.2f\n", mySampleStatsWithMask->sampleMedian); 76 printf("The Sample stdev is %.2f\n", mySampleStatsWithMask->sampleStdev); 77 printf("The Sample quartiles are (%.2f %.2f)\n", mySampleStatsWithMask->sampleLQ, mySampleStatsWithMask->sampleUQ); 78 psFree(mySampleStatsWithMask); 79 46 80 myStats = psStatsAlloc( PS_STAT_ROBUST_MEAN | 47 81 PS_STAT_ROBUST_MEDIAN | … … 49 83 PS_STAT_ROBUST_STDEV | 50 84 PS_STAT_ROBUST_QUARTILE ); 51 52 maskVector = psVectorAlloc( N, PS_TYPE_U8 );53 maskVector->n = N;54 myVector = p_psGaussianDev( MEAN, STDEV, N );55 85 // Create a full outliers: 56 86 myVector->data.F32[N/4] = -1000.0 * MEAN; 57 87 myVector->data.F32[N/2] = 1000.0 * MEAN; 58 // Set the mask vector and calculate the expected maximum.59 for ( i = 0;i < N;i++ ) {60 if ( i < ( N / 2 ) ) {61 maskVector->data.U8[ i ] = 0;62 count++;63 } else {64 maskVector->data.U8[ i ] = 1;65 }66 }67 88 /*************************************************************************/ 68 89 /* Call psVectorStats() with no vector mask. */
Note:
See TracChangeset
for help on using the changeset viewer.
