Changeset 15126
- Timestamp:
- Sep 29, 2007, 1:58:55 PM (19 years ago)
- File:
-
- 1 edited
-
trunk/psLib/src/math/psStats.c (modified) (8 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/psLib/src/math/psStats.c
r15048 r15126 13 13 * use ->min and ->max (PS_STAT_USE_RANGE) 14 14 * 15 * @version $Revision: 1.21 7$ $Name: not supported by cvs2svn $16 * @date $Date: 2007-09-2 8 00:36:30$15 * @version $Revision: 1.218 $ $Name: not supported by cvs2svn $ 16 * @date $Date: 2007-09-29 23:58:55 $ 17 17 * 18 18 * Copyright 2006 IfA, University of Hawaii … … 744 744 long binLo, binHi; 745 745 long binL2, binH2; 746 long binL4, binH4; 746 747 long binMedian; 747 748 … … 842 843 PS_BIN_FOR_VALUE(binL2, cumulative->nums, totalDataPoints * 0.308538f, 0); 843 844 PS_BIN_FOR_VALUE(binH2, cumulative->nums, totalDataPoints * 0.691462f, 0); 845 PS_BIN_FOR_VALUE(binL4, cumulative->nums, totalDataPoints * 0.022481f, 0); 846 PS_BIN_FOR_VALUE(binH4, cumulative->nums, totalDataPoints * 0.977519f, 0); 844 847 845 848 psTrace(TRACE, 6, "The 15.8655%% and 84.1345%% data point bins are (%ld, %ld).\n", … … 864 867 // containing the value of interest. constrain the answer to be within the current bin. 865 868 // (extrapolation should not be needed and will result in errors) 866 float binLoF32, binHiF32, binL2F32, binH2F32 ;867 PS_BIN_INTERPOLATE (binLoF32, cumulative->nums, cumulative->bounds, binL 2, totalDataPoints * 0.158655f);868 PS_BIN_INTERPOLATE (binHiF32, cumulative->nums, cumulative->bounds, binH 2, totalDataPoints * 0.841345f);869 float binLoF32, binHiF32, binL2F32, binH2F32, binL4F32, binH4F32; 870 PS_BIN_INTERPOLATE (binLoF32, cumulative->nums, cumulative->bounds, binLo, totalDataPoints * 0.158655f); 871 PS_BIN_INTERPOLATE (binHiF32, cumulative->nums, cumulative->bounds, binHi, totalDataPoints * 0.841345f); 869 872 PS_BIN_INTERPOLATE (binL2F32, cumulative->nums, cumulative->bounds, binL2, totalDataPoints * 0.308538f); 870 873 PS_BIN_INTERPOLATE (binH2F32, cumulative->nums, cumulative->bounds, binH2, totalDataPoints * 0.691462f); 874 PS_BIN_INTERPOLATE (binL4F32, cumulative->nums, cumulative->bounds, binL4, totalDataPoints * 0.022481f); 875 PS_BIN_INTERPOLATE (binH4F32, cumulative->nums, cumulative->bounds, binH4, totalDataPoints * 0.977519f); 871 876 872 877 // report +/- 1 sigma points … … 874 879 "The exact 15.8655 and 84.1345 percent data point positions are: (%f, %f)\n", 875 880 binLoF32, binHiF32); 876 877 // ADD step 5: Determine SIGMA as (1/2 of) the distance between these positions. 878 // sigma = (binHiF32 - binLoF32) / 2.0; 879 sigma = (binH2F32 - binL2F32); 881 psTrace(TRACE, 5, 882 "The exact 30.8538 and 69.1462 percent data point positions are: (%f, %f)\n", 883 binL2F32, binH2F32); 884 psTrace(TRACE, 5, 885 "The exact 02.22481 and 97.7519 percent data point positions are: (%f, %f)\n", 886 binL4F32, binH4F32); 887 888 // ADD step 5: Determine SIGMA as the distance between binL2 and binH2 (+/- 0.5 sigma) 889 float sigma1 = (binH2F32 - binL2F32); 890 float sigma2 = (binHiF32 - binLoF32) / 2.0; 891 float sigma4 = (binH4F32 - binL4F32) / 4.0; 892 893 // take the smallest of the three: if we have a clump with wide outliers, sigma2 and 894 // sigma4 will be biased high; if we have a bi-modal distribution, sigma1 and sigma2 895 // will be biased high. 896 sigma = PS_MIN (sigma1, PS_MIN (sigma2, sigma4)); 897 898 psTrace(TRACE, 6, "The 2x sigma is %f.\n", sigma1); 899 psTrace(TRACE, 6, "The 2x sigma is %f.\n", sigma2); 900 psTrace(TRACE, 6, "The 4x sigma is %f.\n", sigma4); 880 901 881 902 psTrace(TRACE, 6, "The current sigma is %f.\n", sigma); … … 1698 1719 // XXX can we calculate the binMin, binMax **before** building this histogram? 1699 1720 // if the range is too absurd, adjust numBins & binSize 1700 long numBins = PS_MAX (5 , PS_MIN (10000, (max - min) / binSize));1721 long numBins = PS_MAX (50, PS_MIN (10000, (max - min) / binSize)); 1701 1722 binSize = (max - min) / (float) numBins; 1702 1723 psTrace(TRACE, 6, "The new min/max values are (%f, %f).\n", min, max); … … 1846 1867 1847 1868 // if we converge on a solution outside the range binMin - binMax, use a more conservative range 1848 if (done && (guessMean > PS_BIN_MIDPOINT(histogram, binMax - 1))) { 1869 float minValue = PS_BIN_MIDPOINT(histogram, binMin); 1870 float maxValue = PS_BIN_MIDPOINT(histogram, binMax - 1); 1871 1872 if (done && ((guessMean < minValue) || (guessMean > maxValue))) { 1849 1873 psTrace(TRACE, 6, "Inconsistent result, re-trying the fit\n"); 1850 1874 … … 1904 1928 psTrace(TRACE, 6, "The symmetric stdev is %f.\n", guessStdev); 1905 1929 #endif 1930 1931 // if we converge on a solution outside the range binMin - binMax, use a more conservative range 1932 float minValueSym = PS_BIN_MIDPOINT(histogram, binS); 1933 float maxValueSym = PS_BIN_MIDPOINT(histogram, binE - 1); 1934 1935 // saturate on min or max value 1936 if (guessMean < minValueSym) { 1937 guessMean = minValueSym; 1938 psTrace(TRACE, 6, "The symmetric mean is out of bounds, saturating to %f.\n", guessMean); 1939 } 1940 1941 // saturate on min or max value 1942 if (guessMean > maxValueSym) { 1943 guessMean = maxValueSym; 1944 psTrace(TRACE, 6, "The symmetric mean is out of bounds, saturating to %f.\n", guessMean); 1945 } 1906 1946 1907 1947 psFree (poly);
Note:
See TracChangeset
for help on using the changeset viewer.
