IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 36238


Ignore:
Timestamp:
Oct 25, 2013, 3:49:50 PM (13 years ago)
Author:
watersc1
Message:

Fix final error in fitted stats: Ensure that the binsize does not become large relative to the sigma value.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/psLib/src/math/psStats.c

    r36237 r36238  
    10481048
    10491049       
    1050 #if (0)
     1050#if (CZW)
    10511051        printf("CZW: bad sigma?: %f %f  %f %f  %f %f  %f %f %f  %f\n",
    10521052               binH2F32,binL2F32,binHiF32,binLoF32,binH4F32,binL4F32,
     
    12891289        // XXX can we calculate the binMin, binMax **before** building this histogram?
    12901290        // if the range is too absurd, adjust numBins & binSize
     1291        // We no longer want to reset the binSize here, as it can cause odd things.  Better to select
     1292        // a number of bins, and then set the min/max values to put those bins sanely around the mean.
    12911293        long numBins = PS_MAX (50, PS_MIN (10000, (max - min) / binSize));
    1292         binSize = (max - min) / (float) numBins;
     1294        //        binSize = (max - min) / (float) numBins;
    12931295        psTrace(TRACE, 6, "The new min/max values are (%f, %f).\n", min, max);
    12941296        psTrace(TRACE, 6, "The new bin size is %f.\n", binSize);
     
    12961298
    12971299
     1300#define FITTED_CLIPPING_NUM 5.0
     1301        if (min < guessMean - FITTED_CLIPPING_NUM * guessStdev) {
     1302          min = guessMean - FITTED_CLIPPING_NUM * guessStdev;
     1303        }
     1304        if (max > guessMean + FITTED_CLIPPING_NUM * guessStdev) {
     1305          max = guessMean + FITTED_CLIPPING_NUM * guessStdev;
     1306        }
     1307       
    12981308        psHistogram *histogram = psHistogramAlloc(min, max, numBins); // A new histogram (without outliers)
    12991309        if (!psVectorHistogram(histogram, myVector, errors, mask, maskVal)) {
     
    13301340        PS_BIN_FOR_VALUE (binMin, histogram->bounds, guessMean - minFitSigma*guessStdev, 0);
    13311341        PS_BIN_FOR_VALUE (binMax, histogram->bounds, guessMean + maxFitSigma*guessStdev, 0);
     1342
    13321343        if (binMin == binMax) {
    13331344            COUNT_WARNING(10, 100, "Failed to calculate the min/max of the input vector.\n");
     
    13561367        psTrace(TRACE, 6, "The clipped peak value is %f\n", histogram->nums->data.F32[binPeak]);
    13571368
     1369       
    13581370        float lowfitMean = NAN;
    13591371        float lowfitStdev = NAN;
Note: See TracChangeset for help on using the changeset viewer.