IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Sep 27, 2005, 1:19:47 PM (21 years ago)
Author:
gusciora
Message:

Incorporates new prototypes for the spline functions.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/psLib/test/math/tst_psStats07.c

    r5117 r5155  
    4444    /*  Allocate and initialize data structures                              */
    4545    /*************************************************************************/
     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
    4680    myStats = psStatsAlloc( PS_STAT_ROBUST_MEAN |
    4781                            PS_STAT_ROBUST_MEDIAN |
     
    4983                            PS_STAT_ROBUST_STDEV |
    5084                            PS_STAT_ROBUST_QUARTILE );
    51 
    52     maskVector = psVectorAlloc( N, PS_TYPE_U8 );
    53     maskVector->n = N;
    54     myVector = p_psGaussianDev( MEAN, STDEV, N );
    5585    // Create a full outliers:
    5686    myVector->data.F32[N/4] = -1000.0 * MEAN;
    5787    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     }
    6788    /*************************************************************************/
    6889    /*  Call psVectorStats() with no vector mask.                            */
Note: See TracChangeset for help on using the changeset viewer.