IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Sep 23, 2005, 1:01:30 PM (21 years ago)
Author:
gusciora
Message:

The purpose of this check-in is primarily to put the new robusts stats
code and tests into the CVS tree.

File:
1 edited

Legend:

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

    r4861 r5113  
    3434    float realMeanNoMask = MEAN;
    3535    float realMedianNoMask = MEAN;
    36     float realModeNoMask = MEAN;
    37     float realStdevNoMask = STDEV * 0.20;
     36    //    float realModeNoMask = MEAN;
     37    float realStdevNoMask = STDEV;
    3838    float realLQNoMask = MEAN - ( 0.6 * STDEV );
    3939    float realUQNoMask = MEAN + ( 0.6 * STDEV );
    4040    psS32 realN50NoMask = N / 4;
    4141    psS32 realNfitNoMask = N / 4;
    42 
    43     psTraceSetLevel(".psLib.dataManip", 0);
    4442
    4543    /*************************************************************************/
     
    5553    maskVector->n = N;
    5654    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;
    5758    // Set the mask vector and calculate the expected maximum.
    5859    for ( i = 0;i < N;i++ ) {
     
    7273
    7374    myStats = psVectorStats( myStats, myVector, NULL, NULL, 0 );
     75    if (myStats == NULL) {
     76        printf("TEST ERROR: psVectorStats() returned NULL.\n");
     77        return(false);
     78    }
    7479
    7580    printf( "The expected Mean was %.2f; the calculated Mean was %.2f\n",
     
    105110                 testStatus );
    106111
    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    */
    126131
    127132    printPositiveTestHeader( stdout,
     
    143148
    144149
    145 
    146150    printPositiveTestHeader( stdout,
    147151                             "psStats functions",
     
    161165                 "PS_STAT_ROBUST_STATS: lower quartile: no vector mask",
    162166                 testStatus );
    163 
    164 
    165167
    166168    printPositiveTestHeader( stdout,
     
    180182                 "PS_STAT_ROBUST_STATS: lower quartile: no vector mask",
    181183                 testStatus );
    182 
    183 
    184184
    185185    printPositiveTestHeader( stdout,
     
    205205                 testStatus );
    206206
    207 
    208 
    209207    printPositiveTestHeader( stdout,
    210208                             "psStats functions",
     
    228226                 "PS_STAT_ROBUST_STATS: robust Nfit: no vector mask",
    229227                 testStatus );
    230     return(testStatus);
    231228
    232229    /*************************************************************************/
     
    252249                 testStatus );
    253250
    254     if (globalTestStatus == false)
    255         printf("Returning FALSE\n");
    256     else
    257         printf("Returning TRUE\n");
    258     return ( !globalTestStatus );
     251    return ( globalTestStatus );
    259252}
    260253
     
    276269    float realMeanWithMask = MEAN;
    277270    float realMedianWithMask = MEAN;
    278     float realModeWithMask = MEAN;
    279     float realStdevWithMask = STDEV * 0.20;
     271    //    float realModeWithMask = MEAN;
     272    float realStdevWithMask = STDEV;
    280273    float realLQWithMask = MEAN;
    281274    float realUQWithMask = MEAN;
    282275    psS32 realN50WithMask = N / 4;
    283276    psS32 realNfitWithMask = N / 4;
    284 
    285     psTraceSetLevel(".psLib.dataManip.psStats", 0);
    286 
    287277    /*************************************************************************/
    288278    /*  Allocate and initialize data structures                              */
     
    316306    printf( "Calling psVectorStats() on a vector with elements masked.\n" );
    317307    myStats = psVectorStats( myStats, myVector, NULL, maskVector, 1 );
     308    if (myStats == NULL) {
     309        printf("TEST ERROR: psVectorStats() returned NULL.\n");
     310        return(false);
     311    }
    318312    printf( "Called psVectorStats() on a vector with elements masked.\n" );
    319313    printf( "The expected Mean was %.2f; the calculated Mean was %.2f\n",
     
    348342
    349343
    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    */
    368362
    369363
     
    489483                 testStatus );
    490484
    491     if (globalTestStatus == false)
    492         printf("Returning FALSE\n");
    493     else
    494         printf("Returning TRUE\n");
    495 
    496     return ( !globalTestStatus );
     485    return ( globalTestStatus );
    497486}
    498487
     
    500489{
    501490    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);
    506497}
Note: See TracChangeset for help on using the changeset viewer.