Changeset 19965 for trunk/ppStats/src/ppStatsFromMetadataStats.c
- Timestamp:
- Oct 7, 2008, 2:47:49 PM (18 years ago)
- File:
-
- 1 edited
-
trunk/ppStats/src/ppStatsFromMetadataStats.c (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
trunk/ppStats/src/ppStatsFromMetadataStats.c
r19955 r19965 2 2 3 3 // calculate the stats for the non-constant entries (already calculated) 4 bool ppStatsFromMetadataStats (psArray *entries) { 5 6 double value; 7 psStats *stats = NULL; 4 bool ppStatsFromMetadataStats(psArray *entries) { 8 5 9 6 for (int i = 0; i < entries->n; i++) { 10 ppStatsEntry *entry = entries->data[i];7 ppStatsEntry *entry = entries->data[i]; 11 8 12 if (!strcasecmp (entry->statistic, "constant")) continue; 13 14 // XXX skip or warn on missing stats? 15 if (!entry->vector) continue; 9 if (!strcasecmp(entry->statistic, "constant")) { 10 continue; 11 } 16 12 17 psStatsOptions option; 18 if (!strcasecmp (entry->statistic, "RMS")) { 19 option = psStatsOptionFromString ("ROBUST_MEDIAN"); 20 goto got_stats; 21 } 22 if (!strcasecmp (entry->statistic, "SUM")) { 23 option = psStatsOptionFromString ("SAMPLE_MEAN"); 24 goto got_stats; 25 } 26 if (!strcasecmp (entry->statistic, "UQ")) { 27 option = psStatsOptionFromString ("ROBUST_QUARTILE"); 28 goto got_stats; 29 } 30 if (!strcasecmp (entry->statistic, "LQ")) { 31 option = psStatsOptionFromString ("ROBUST_QUARTILE"); 32 goto got_stats; 33 } 13 // XXX skip or warn on missing stats? 14 if (!entry->vector) { 15 continue; 16 } 34 17 35 option = psStatsOptionFromString (entry->statistic); 36 37 got_stats: 38 stats = psStatsAlloc (option); 18 psStatsOptions option; 19 if (!strcasecmp (entry->statistic, "RMS")) { 20 option = psStatsOptionFromString ("ROBUST_MEDIAN"); 21 } else if (!strcasecmp (entry->statistic, "SUM")) { 22 option = psStatsOptionFromString ("SAMPLE_MEAN"); 23 } else if (!strcasecmp (entry->statistic, "UQ")) { 24 option = psStatsOptionFromString ("ROBUST_QUARTILE"); 25 } else if (!strcasecmp (entry->statistic, "LQ")) { 26 option = psStatsOptionFromString ("ROBUST_QUARTILE"); 27 } else { 28 option = psStatsOptionFromString (entry->statistic); 29 } 39 30 40 psVectorStats (stats, entry->vector, NULL, NULL, 0);31 psStats *stats = psStatsAlloc(option); 41 32 42 if (!strcasecmp (entry->statistic, "RMS")) { 43 value = sqrt(value); 44 goto got_value; 45 } 46 if (!strcasecmp (entry->statistic, "SUM")) { 47 value = stats->sampleMean * entry->vector->n; 48 goto got_value; 49 } 50 if (!strcasecmp (entry->statistic, "UQ")) { 51 value = stats->robustUQ; 52 goto got_value; 53 } 54 if (!strcasecmp (entry->statistic, "LQ")) { 55 value = stats->robustLQ; 56 goto got_value; 57 } 58 value = psStatsGetValue (stats, option); 33 psVectorStats(stats, entry->vector, NULL, NULL, 0); 59 34 60 got_value: 61 entry->value = psMetadataItemAllocF32 (entry->keyword, entry->statistic, value); 35 double value; 36 if (!strcasecmp (entry->statistic, "RMS")) { 37 value = sqrt(value); 38 } else if (!strcasecmp (entry->statistic, "SUM")) { 39 value = stats->sampleMean * entry->vector->n; 40 } else if (!strcasecmp (entry->statistic, "UQ")) { 41 value = stats->robustUQ; 42 } else if (!strcasecmp (entry->statistic, "LQ")) { 43 value = stats->robustLQ; 44 } else { 45 value = psStatsGetValue (stats, option); 46 } 47 entry->value = psMetadataItemAllocF32(entry->keyword, entry->statistic, value); 48 psFree(stats); 62 49 } 63 50 return true;
Note:
See TracChangeset
for help on using the changeset viewer.
