IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 30076


Ignore:
Timestamp:
Dec 16, 2010, 6:11:16 PM (15 years ago)
Author:
eugene
Message:

add sample data cases for tap_psStats_Sample_01.c and a mana script to plot the data; add an interesting odd data sample case to the mix

Location:
branches/eam_branches/ipp-20101205/psLib/test/math
Files:
5 added
1 edited

Legend:

Unmodified
Added
Removed
  • branches/eam_branches/ipp-20101205/psLib/test/math/tap_psStats_Sample_01.c

    r12513 r30076  
    487487                         };
    488488
     489static float yraw_04[] = {
     490    -1.000000, 0.000000, 0.000000, 0.000000, 0.000000, -1.000000, -1.000000, -1.000000,
     491    0.000000, -1.000000, -1.000000, -1.000000, -1.000000, -1.000000, -1.000000, -1.000000,
     492    -1.000000, -1.000000, -1.000000, -1.000000, -1.000000, -1.000000, -1.000000, -0.963289,
     493    -1.000000, 0.000000, -1.000000, -1.000000, -0.915174, -1.000000, -1.000000, -1.000000,
     494    -1.000000, -1.000000, 0.000000, -1.000000, -1.000000, -1.000000, -1.000000, -1.000000,
     495    -1.000000, -1.000000, -1.000000, -0.853025, 0.000000, -1.000000, -1.000000, -1.000000,
     496    -1.000000, -1.000000, -1.000000, -1.000000, -1.000000, -0.989926, -1.000000, -1.000000,
     497    -1.000000, -1.000000, -1.000000, -1.000000, -1.000000, -0.834902, -1.000000, -1.000000,
     498    -0.942985, -1.000000, -1.000000, 0.000000, -1.000000, -1.000000, -1.000000, -1.000000,
     499    -1.000000, -1.000000, -0.990081, -1.000000, -0.990456, -0.814654, -1.000000, -1.000000,
     500    -1.000000, -1.000000, 0.000000, -1.000000, -1.000000, -1.000000, -1.000000, -1.000000,
     501    -0.968021, -1.000000, -1.000000, 0.000000, -1.000000, -1.000000, -0.993967, -0.957540,
     502    -0.894533, -0.958363, -1.000000, -1.000000, -1.000000, -0.988915, -1.000000, -1.000000,
     503    -1.000000, -1.000000, -1.000000, -1.000000, -0.985367, -1.000000, -0.972040, -1.000000,
     504    -1.000000, -1.000000, 0.000000, -1.000000, -0.882278, -1.000000, -1.000000, -1.000000,
     505    -1.000000, -1.000000, -1.000000, -1.000000, -1.000000, -1.000000, -1.000000, -1.000000,
     506    -1.000000, -0.962575, -0.976843, -0.998926, -1.000000, -0.914090, 0.000000, -0.957808,
     507    -1.000000, -1.000000, -1.000000, 0.000000, -0.902593, -1.000000, -1.000000, -1.000000,
     508    -1.000000, -1.000000, -1.000000, -1.000000, -1.000000, -1.000000, -1.000000, -0.975404,
     509    -1.000000, 0.000000, -0.984627, -1.000000, -0.969547, -0.851295, -1.000000, -0.988146,
     510    -1.000000, 0.000000, -1.000000, -0.993753, -0.861851, -1.000000, -0.980836, -0.979644,
     511    -1.000000, -1.000000, -1.000000, -0.995401, -1.000000, -1.000000, -1.000000, -1.000000,
     512    -1.000000, -1.000000, -1.000000, -1.000000, -1.000000, -1.000000, -1.000000, -1.000000,
     513    0.000000, -1.000000, -0.990123, -0.944934, -1.000000, 0.000000, -1.000000, -0.952198,
     514    -1.000000, -1.000000, -0.960814, -1.000000, -1.000000, -1.000000, -0.956806, -1.000000,
     515    0.000000, -0.991778, -1.000000, -1.000000, -1.000000, -1.000000, 0.000000, -1.000000,
     516    -0.977640, -1.000000, -1.000000, 0.000000, -1.000000, -0.977630, -1.000000, -0.974242,
     517    -1.000000, -1.000000, -0.940085, -0.930729, -1.000000, -1.000000, 0.000000, -1.000000,
     518    -1.000000, -0.933695, -1.000000, -0.932306, -1.000000, -1.000000, -1.000000, -0.836774,
     519    -0.931762, -0.926990, -0.861895, -1.000000, -0.922505, -1.000000, -0.956420, -0.998768,
     520    -0.974626, -0.964573, -1.000000, -0.933995, -1.000000, -0.995117, -1.000000, -1.000000,
     521    0.000000, 0.000000, -1.000000, -0.955537, -0.996360, -0.988015, -1.000000, -1.000000,
     522    -0.963953, -0.920429, -0.955252, -0.950946, -1.000000, -1.000000, -1.000000, -0.979526,
     523    -1.000000, -1.000000, -0.997193, -1.000000, -1.000000, 0.000000, -1.000000, -1.000000,
     524    -1.000000, -0.893445, -1.000000, -1.000000, -0.997704, -1.000000, -1.000000, -0.952295,
     525    -1.000000, 0.000000, -0.928042, -1.000000, -1.000000, -0.994029, -0.919350, -1.000000,
     526    -1.000000, -1.000000, -1.000000, -0.958966, -0.806458, -0.903843, -1.000000, -1.000000,
     527    -1.000000, -1.000000, -1.000000, -1.000000, 0.000000, -0.989002, 0.000000, -0.999874,
     528    -1.000000, 0.000000, -1.000000, 0.000000, -0.923556, -0.906242, -0.923497, -0.997873,
     529    -1.000000, -1.000000, 0.000000, -0.960376, -0.998760, -1.000000, 0.000000, -1.000000,
     530    -0.852141, -1.000000, -0.957442, -0.942000, -1.000000, -1.000000, -1.000000, -1.000000,
     531    -1.000000, -1.000000, -0.996748, -0.997676, -0.976159, -0.951572, -1.000000, -0.993083,
     532    -0.715375, -0.997984, -1.000000, -0.962484, -0.996733, -1.000000, -1.000000, -0.953423,
     533    -1.000000, -0.882232, -1.000000, -1.000000, -0.944493, -1.000000, -0.979617, -1.000000,
     534    -0.990002, -1.000000, -0.844745, -0.945080, -1.000000, -1.000000, -0.904816, -1.000000,
     535    -0.986999, -1.000000, -0.854941, -1.000000, -0.946096, -0.977678, -1.000000, -0.955933,
     536    -0.979545, -1.000000, -1.000000, -0.863616, -0.973953, -0.996599, -0.990304, -0.978263,
     537    -1.000000, -0.967798, -0.912566, 0.000000, -1.000000, -1.000000, -0.990321, -0.995921,
     538    -1.000000, -1.000000, -1.000000, -0.927030, -0.886393, -0.987297, -1.000000, -1.000000,
     539    -0.987206, -0.978084, -1.000000, -0.923876, -0.957539, -0.991587, -0.819295, -1.000000,
     540    -0.985077, -1.000000, 0.000000, -1.000000, -1.000000, -0.822353, -1.000000, -1.000000,
     541    -0.987783, -1.000000, -0.909520, -1.000000, -0.932334, -0.991847, -1.000000, -0.885318,
     542    -0.945695, -0.977144, -0.989444, -0.887085, -0.891662, -0.894193, -1.000000, 0.000000,
     543    -1.000000, -0.917484, -1.000000, -0.892801, -1.000000, -0.963580, -0.869279, -0.965420,
     544    -0.906966, -0.929646, -0.981315, -1.000000, -1.000000, -0.749674, -1.000000, -0.886804,
     545    -1.000000, -1.000000, -1.000000, -1.000000, -1.000000, -1.000000, -0.970826, -0.909766,
     546    -1.000000, -0.910406, -0.983636, -1.000000, -0.961209, -0.935273, -1.000000, -0.989806,
     547    0.000000, -0.981563, -0.989701, -0.915626, -0.997493, -0.981429, -1.000000, -0.964583,
     548    -1.000000, -0.930216, -0.737797, -1.000000, -0.944314, -0.999998, -0.999611, -0.945788,
     549    -0.773886, -0.848979, -0.980186, -1.000000, -1.000000, 0.000000, -0.951392, -0.993398,
     550    -0.931889, -0.991680, -0.959021, -0.904240, -1.000000, -0.983561, -0.821324, 0.000000,
     551    0.000000, -1.000000, -0.925782, -0.841267, -1.000000, -0.907313, -1.000000, -0.990704,
     552    -1.000000, -1.000000, -0.936372, -0.885059
     553};
     554
    489555int main (void)
    490556{
    491557    plan_tests(21);
    492558
    493 //    diag("psStats Tests with sample SDSS data from RHL and Megacam from EAM");
    494 //    diag("this file does not yet define a specific test");
    495 //    diag("the fitted mean is currently wrong for these two data sets");
    496 
    497     {
     559    // float **yraw = {yraw_01, yraw_02, yraw_03, yraw_04, NULL};
     560
     561    if (1) {
     562        diag("sample 1 : problem with integer-binned data driven to tiny sigma values");
     563
    498564        psMemId id = psMemGetId();
    499565
    500 //        diag("sample 1 : problem with integer-binned data driven to tiny sigma values");
    501566        psStats *stats = psStatsAlloc (PS_STAT_FITTED_MEAN | PS_STAT_FITTED_STDEV |
    502567                                       PS_STAT_ROBUST_MEDIAN | PS_STAT_ROBUST_STDEV |
     
    505570                                       PS_STAT_SAMPLE_STDEV | PS_STAT_USE_BINSIZE);
    506571        stats->binsize = 1.0;
    507 
    508572
    509573        // copy data in static array
     
    533597
    534598
    535     {
     599    if (1) {
    536600        psMemId id = psMemGetId();
    537601
    538 //        diag("sample 2");
     602        diag("sample 2");
    539603        psStats *stats = psStatsAlloc (PS_STAT_FITTED_MEAN | PS_STAT_FITTED_STDEV |
    540604                                       PS_STAT_ROBUST_MEDIAN | PS_STAT_ROBUST_STDEV |
     
    568632    }
    569633
    570     {
     634    if (1) {
    571635        psMemId id = psMemGetId();
    572636
    573 //        diag("sample 3");
     637        diag("sample 3");
    574638        psStats *stats = psStatsAlloc (PS_STAT_FITTED_MEAN | PS_STAT_FITTED_STDEV |
    575639                                       PS_STAT_ROBUST_MEDIAN | PS_STAT_ROBUST_STDEV |
    576640                                       PS_STAT_CLIPPED_MEAN | PS_STAT_CLIPPED_STDEV |
    577641                                       PS_STAT_SAMPLE_MEAN | PS_STAT_SAMPLE_MEDIAN |
    578                                        PS_STAT_SAMPLE_STDEV | PS_STAT_USE_BINSIZE);
    579         stats->binsize = 1.0;
    580 
     642                                       PS_STAT_SAMPLE_STDEV);
    581643
    582644        // copy data in static array
     
    605667    }
    606668
     669    {
     670        psMemId id = psMemGetId();
     671
     672        // psTraceSetLevel("psLib.math.vectorRobustStats", 6);
     673
     674        diag("sample 4");
     675        psStats *stats = psStatsAlloc (PS_STAT_FITTED_MEAN | PS_STAT_FITTED_STDEV |
     676                                       PS_STAT_ROBUST_MEDIAN | PS_STAT_ROBUST_STDEV |
     677                                       PS_STAT_CLIPPED_MEAN | PS_STAT_CLIPPED_STDEV |
     678                                       PS_STAT_SAMPLE_MEAN | PS_STAT_SAMPLE_MEDIAN |
     679                                       PS_STAT_SAMPLE_STDEV);
     680
     681        // copy data in static array
     682        int nPts = sizeof(yraw_04) / sizeof (float);
     683        psVector *y = psVectorAlloc (nPts, PS_TYPE_F32);
     684        for (int i = 0; i < y->n; i++) {
     685            y->data.F32[i] = yraw_04[i];
     686        }
     687
     688        psVectorStats (stats, y, NULL, NULL, 1);
     689        ok (1, "sample  mean   %f, stdev %f", stats->sampleMean,   stats->sampleStdev);
     690        ok (1, "sample  median %f, stdev %f", stats->sampleMedian, stats->sampleStdev);
     691        ok (1, "clipped mean   %f, stdev %f", stats->clippedMean,  stats->clippedStdev);
     692        ok (1, "robust  median %f, stdev %f", stats->robustMedian, stats->robustStdev);
     693        ok (1, "fitted  mean   %f, stdev %f", stats->fittedMean,   stats->fittedStdev);
     694        psFree (stats);
     695
     696        stats = psStatsAlloc (PS_STAT_FITTED_MEAN_V2 | PS_STAT_FITTED_STDEV_V2 | PS_STAT_USE_BINSIZE);
     697        stats->binsize = 1.0;
     698        psVectorStats (stats, y, NULL, NULL, 1);
     699        ok (1, "fitted  mean v2 %f, stdev %f", stats->fittedMean,   stats->fittedStdev);
     700        psFree (stats);
     701
     702        psFree (y);
     703        ok(!psMemCheckLeaks (id, NULL, NULL, false), "no memory leaks");
     704    }
     705
    607706    return exit_status();
    608707}
     708
Note: See TracChangeset for help on using the changeset viewer.