Changeset 3547
- Timestamp:
- Mar 29, 2005, 12:34:59 PM (21 years ago)
- Location:
- trunk/psLib/src
- Files:
-
- 6 edited
-
dataManip/psMinimize.c (modified) (5 diffs)
-
dataManip/psStats.c (modified) (10 diffs)
-
dataManip/psStats.h (modified) (3 diffs)
-
math/psMinimize.c (modified) (5 diffs)
-
math/psStats.c (modified) (10 diffs)
-
math/psStats.h (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/psLib/src/dataManip/psMinimize.c
r3540 r3547 9 9 * @author GLG, MHPCC 10 10 * 11 * @version $Revision: 1.10 8$ $Name: not supported by cvs2svn $12 * @date $Date: 2005-03-29 19:41:56$11 * @version $Revision: 1.109 $ $Name: not supported by cvs2svn $ 12 * @date $Date: 2005-03-29 22:34:59 $ 13 13 * 14 14 * Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii … … 786 786 // 787 787 if (currChi2 > newChi2) { 788 min->lastDelta = currChi2 - newChi2;788 min->lastDelta = (currChi2 - newChi2)/currChi2; 789 789 min->value = newChi2; 790 790 … … 1406 1406 with an initial guess at the parameters of that function and vector "line" 1407 1407 of the same size as the parameter vector. It will minimize the function 1408 along that vector an rreturns the offset along that vector at which the1408 along that vector and returns the offset along that vector at which the 1409 1409 minimum is determined. 1410 1410 … … 1713 1713 psFree(v); 1714 1714 min->iter = iterationNumber; 1715 // XXX: Ensure that currFuncVal is the correct value to use here. 1716 min->value = currFuncVal; 1715 1717 psTrace(".psLib.dataManip.psMinimizePowell", 4, 1716 1718 "---- psMinimizePowell() end (1)(true) ----\n"); … … 1749 1751 if (fabs(baseFuncVal - currFuncVal) <= min->tol) { 1750 1752 psFree(v); 1753 // XXX: Ensure that currFuncVal is the correct value to use here. 1754 min->value = currFuncVal; 1751 1755 min->iter = iterationNumber; 1752 1756 psTrace(".psLib.dataManip.psMinimizePowell", 4, -
trunk/psLib/src/dataManip/psStats.c
r3540 r3547 9 9 * @author GLG, MHPCC 10 10 * 11 * @version $Revision: 1.12 2$ $Name: not supported by cvs2svn $12 * @date $Date: 2005-03-29 19:41:56$11 * @version $Revision: 1.123 $ $Name: not supported by cvs2svn $ 12 * @date $Date: 2005-03-29 22:34:59 $ 13 13 * 14 14 * Copyright 2004 Maui High Performance Computing Center, University of Hawaii … … 1489 1489 if (fabs(binSize) <= FLT_EPSILON) { 1490 1490 if (stats->options & PS_STAT_ROBUST_MEAN) { 1491 stats->robustMean = stats->clippedMean;1491 stats->robustMean = tmpStats->clippedMean; 1492 1492 } 1493 1493 if (stats->options & PS_STAT_ROBUST_MEDIAN) { 1494 stats->robustMedian = stats->clippedMean;1494 stats->robustMedian = tmpStats->clippedMean; 1495 1495 } 1496 1496 if (stats->options & PS_STAT_ROBUST_MODE) { 1497 stats->robustMode = stats->clippedMean;1497 stats->robustMode = tmpStats->clippedMean; 1498 1498 } 1499 1499 if (stats->options & PS_STAT_ROBUST_STDEV) { … … 1501 1501 } 1502 1502 if (stats->options & PS_STAT_ROBUST_QUARTILE) { 1503 stats->robustUQ = stats->clippedMean;1504 stats->robustLQ = stats->clippedMean;1503 stats->robustUQ = tmpStats->clippedMean; 1504 stats->robustLQ = tmpStats->clippedMean; 1505 1505 } 1506 1506 // XXX: Set these to the number of unmasked data points? … … 1512 1512 1513 1513 // Determine minimum and maximum values in the data vector. 1514 if (isnan( stats->min)) {1515 if (0 != p_psVectorMin(myVector, maskVector, maskVal, stats)) {1514 if (isnan(tmpStats->min)) { 1515 if (0 != p_psVectorMin(myVector, maskVector, maskVal, tmpStats)) { 1516 1516 psLogMsg(__func__, PS_LOG_WARN, 1517 1517 "WARNING: p_psVectorMin(): p_psVectorMin() reported a NAN mean.\n"); … … 1519 1519 } 1520 1520 } 1521 if (isnan( stats->max)) {1522 if (0 != p_psVectorMax(myVector, maskVector, maskVal, stats)) {1521 if (isnan(tmpStats->max)) { 1522 if (0 != p_psVectorMax(myVector, maskVector, maskVal, tmpStats)) { 1523 1523 psLogMsg(__func__, PS_LOG_WARN, 1524 1524 "WARNING: p_psVectorMin(): p_psVectorMax() reported a NAN mean.\n"); … … 1531 1531 // bins, not the binSize. Also, if we get here, we know that 1532 1532 // binSize != 0.0. 1533 numBins = (psS32)(( stats->max - stats->min) / binSize);1534 robustHistogram = psHistogramAlloc( stats->min, stats->max, numBins);1533 numBins = (psS32)((tmpStats->max - tmpStats->min) / binSize); 1534 robustHistogram = psHistogramAlloc(tmpStats->min, tmpStats->max, numBins); 1535 1535 1536 1536 // Populate the histogram array. … … 1620 1620 myStdev = PS_SQRT_F32((sumSquares - (sumDiffs * sumDiffs / countFloat)) / (countFloat - 1)); 1621 1621 1622 // Using the above (myMean, myStdev) as initial estimates, we fit a1623 // Gaussian to the robustHistogramVector.1624 psMinimization *min = psMinimizationAlloc(100, 0.1);1625 psVector *myParams = psVectorAlloc(2, PS_TYPE_F32);1626 psArray *myCoords = psArrayAlloc(robustHistogramVector->n);1627 psVector *y = psVectorAlloc(robustHistogramVector->n, PS_TYPE_F32);1628 1629 1622 p_psNormalizeVectorRangeF32(robustHistogramVector, 0.0, 1.0); 1630 for (i=0;i<robustHistogramVector->n;i++) { 1631 myCoords->data[i] = (psPtr *) psVectorAlloc(2, PS_TYPE_F32); 1632 ((psVector *) (myCoords->data[i]))->data.F32[0] = (psF32) i; 1633 y->data.F32[i] = robustHistogramVector->data.F32[i]; 1634 } 1635 1636 myParams->data.F32[0] = myMean; 1637 myParams->data.F32[1] = myStdev; 1638 psImage *covar = NULL; 1639 psMinimizeLMChi2(min, 1640 NULL, 1641 myParams, 1642 NULL, 1643 myCoords, 1644 y, 1645 NULL, 1646 (psMinimizeLMChi2Func) psMinimizeLMChi2Gauss1D); 1647 psFree(covar); 1648 psFree(min); 1649 psFree(myParams); 1650 psFree(myCoords); 1651 psFree(y); 1623 1624 if ((stats->options & PS_STAT_ROBUST_MEAN) || 1625 (stats->options & PS_STAT_ROBUST_STDEV)) { 1626 1627 // Using the above (myMean, myStdev) as initial estimates, we fit a 1628 // Gaussian to the robustHistogramVector. 1629 psImage *covar = NULL; 1630 psMinimization *min = psMinimizationAlloc(100, 0.1); 1631 psVector *myParams = psVectorAlloc(2, PS_TYPE_F32); 1632 psArray *myCoords = psArrayAlloc(robustHistogramVector->n); 1633 psVector *y = psVectorAlloc(robustHistogramVector->n, PS_TYPE_F32); 1634 1635 1636 myParams->data.F32[0] = myMean; 1637 myParams->data.F32[1] = myStdev; 1638 1639 /* XXX: old. Remove this. 1640 for (i=0;i<robustHistogramVector->n;i++) { 1641 myCoords->data[i] = (psPtr *) psVectorAlloc(2, PS_TYPE_F32); 1642 ((psVector *) (myCoords->data[i]))->data.F32[0] = (psF32) i; 1643 y->data.F32[i] = robustHistogramVector->data.F32[i]; 1644 } 1645 */ 1646 1647 for (i = modeBinNum - dL; i <= modeBinNum + dL; i++) { 1648 int index = i - modeBinNum + dL; 1649 myCoords->data[index] = (psPtr *) psVectorAlloc(2, PS_TYPE_F32); 1650 ((psVector *) (myCoords->data[index]))->data.F32[0] = PS_BIN_MIDPOINT(robustHistogram, i); 1651 y->data.F32[index] = robustHistogramVector->data.F32[i]; 1652 } 1653 1654 bool rc = psMinimizeLMChi2(min, 1655 NULL, 1656 myParams, 1657 NULL, 1658 myCoords, 1659 y, 1660 NULL, 1661 (psMinimizeLMChi2Func) psMinimizeLMChi2Gauss1D); 1662 if (rc == false) { 1663 psLogMsg(__func__, PS_LOG_WARN, 1664 "WARNING: failed to minimize with psMinimizeLMChi2().\n"); 1665 } 1666 1667 // XXX: Verify this with IfA 1668 // XXX: The check on the minimization is better than the difference from myMean. 1669 // Do they still want this code? 1670 1671 if (stats->options & PS_STAT_ROBUST_MEAN) { 1672 if (fabs((myParams->data.F32[0] - myMean)/myMean) > 0.1) { 1673 psLogMsg(__func__, PS_LOG_WARN, 1674 "WARNING: the fitted Gaussian has more than 10%% error for the mean.\n"); 1675 psLogMsg(__func__, PS_LOG_WARN, 1676 "WARNING: Using the calculated mean instead of Gaussian-fitted mean."); 1677 // "WARNING: Using the calculated mean instead of Gaussian-fitted mean.(calc, fit) is (%f, %f)\n", 1678 // myMean, myParams->data.F32[0]); 1679 stats->robustMean = myMean; 1680 } else { 1681 stats->robustMean = myParams->data.F32[0]; 1682 } 1683 } 1684 1685 1686 if (stats->options & PS_STAT_ROBUST_STDEV) { 1687 if (fabs((myParams->data.F32[1] - myStdev)/myStdev) > 0.1) { 1688 psLogMsg(__func__, PS_LOG_WARN, 1689 "WARNING: the fitted Gaussian has more than 10%% error for the stdev.\n"); 1690 psLogMsg(__func__, PS_LOG_WARN, 1691 "WARNING: Using the calculated stdev instead of Gaussian-fitted stdev."); 1692 // "WARNING: Using the calculated stdev instead of Gaussian-fitted stdev.(calc, fit) is (%f, %f)\n", 1693 // myStdev, myParams->data.F32[1]); 1694 stats->robustStdev = myStdev; 1695 } else { 1696 stats->robustStdev = myParams->data.F32[1]; 1697 } 1698 } 1699 psFree(covar); 1700 psFree(min); 1701 psFree(myCoords); 1702 psFree(y); 1703 psFree(myParams); 1704 } 1705 1706 1652 1707 /************************************************************************** 1653 1708 Set the appropriate members in the output stats struct. 1654 1709 **************************************************************************/ 1655 if (stats->options & PS_STAT_ROBUST_MEAN) {1656 if (fabs((myParams->data.F32[0] - myMean)/myMean) > 0.1) {1657 psLogMsg(__func__, PS_LOG_WARN,1658 "WARNING: the fitted Gaussian has more than 10%% error for the mean.\n");1659 psLogMsg(__func__, PS_LOG_WARN,1660 "WARNING: Using the calculated mean instead of Gaussian-fitted mean.");1661 // "WARNING: Using the calculated mean instead of Gaussian-fitted mean.(calc, fit) is (%f, %f)\n",1662 // myMean, myParams->data.F32[0]);1663 stats->robustMean = myMean;1664 } else {1665 stats->robustMean = myParams->data.F32[0];1666 }1667 }1668 1710 1669 1711 if (stats->options & PS_STAT_ROBUST_MODE) { … … 1671 1713 } 1672 1714 1673 if (stats->options & PS_STAT_ROBUST_STDEV) {1674 if (fabs((myParams->data.F32[1] - myStdev)/myStdev) > 0.1) {1675 psLogMsg(__func__, PS_LOG_WARN,1676 "WARNING: the fitted Gaussian has more than 10%% error for the stdev.\n");1677 psLogMsg(__func__, PS_LOG_WARN,1678 "WARNING: Using the calculated stdev instead of Gaussian-fitted stdev.");1679 // "WARNING: Using the calculated stdev instead of Gaussian-fitted stdev.(calc, fit) is (%f, %f)\n",1680 // myStdev, myParams->data.F32[1]);1681 stats->robustStdev = myStdev;1682 } else {1683 stats->robustStdev = myParams->data.F32[1];1684 }1685 }1686 1715 1687 1716 // To determine the median, we fit a quadratic y=f(x) to the three bins … … 2174 2203 *****************************************************************************/ 2175 2204 psStats* psVectorStats(psStats* stats, 2176 psVector* in,2177 psVector* errors,2178 psVector* mask,2205 const psVector* in, 2206 const psVector* errors, 2207 const psVector* mask, 2179 2208 psU32 maskVal) 2180 2209 { … … 2197 2226 inF32 = p_psConvertToF32((psVector *) in); 2198 2227 if (inF32 == NULL) { 2199 inF32 = in;2228 inF32 = (psVector *) in; 2200 2229 mustFreeVectorIn = 0; 2201 2230 } 2202 2231 errorsF32 = p_psConvertToF32((psVector *) errors); 2203 2232 if (errorsF32 == NULL) { 2204 errorsF32 = errors;2233 errorsF32 = (psVector *) errors; 2205 2234 mustFreeVectorErrors = 0; 2206 2235 } -
trunk/psLib/src/dataManip/psStats.h
r3264 r3547 4 4 * @ingroup Stats 5 5 * 6 * This file will hold the definition of the histogram and stats data6 xd * This file will hold the definition of the histogram and stats data 7 7 * structures. It also contains prototypes for procedures which operate 8 8 * on those data structures. … … 10 10 * @author George Gusciora, MHPCC 11 11 * 12 * @version $Revision: 1. 39$ $Name: not supported by cvs2svn $13 * @date $Date: 2005-0 2-17 19:26:23$12 * @version $Revision: 1.40 $ $Name: not supported by cvs2svn $ 13 * @date $Date: 2005-03-29 22:34:59 $ 14 14 * 15 15 * Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii … … 87 87 psStats* psVectorStats( 88 88 psStats* stats, ///< stats structure defines stats to be calculated and how 89 psVector* in, ///< Vector to be analysed.90 psVector* errors, ///< Errors.91 psVector* mask, ///< Ignore elements where (maskVector & maskVal) != 0: must be INT or NULL89 const psVector* in, ///< Vector to be analysed. 90 const psVector* errors, ///< Errors. 91 const psVector* mask, ///< Ignore elements where (maskVector & maskVal) != 0: must be INT or NULL 92 92 psU32 maskVal ///< Only mask elements with one of these bits set in maskVector 93 93 ); -
trunk/psLib/src/math/psMinimize.c
r3540 r3547 9 9 * @author GLG, MHPCC 10 10 * 11 * @version $Revision: 1.10 8$ $Name: not supported by cvs2svn $12 * @date $Date: 2005-03-29 19:41:56$11 * @version $Revision: 1.109 $ $Name: not supported by cvs2svn $ 12 * @date $Date: 2005-03-29 22:34:59 $ 13 13 * 14 14 * Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii … … 786 786 // 787 787 if (currChi2 > newChi2) { 788 min->lastDelta = currChi2 - newChi2;788 min->lastDelta = (currChi2 - newChi2)/currChi2; 789 789 min->value = newChi2; 790 790 … … 1406 1406 with an initial guess at the parameters of that function and vector "line" 1407 1407 of the same size as the parameter vector. It will minimize the function 1408 along that vector an rreturns the offset along that vector at which the1408 along that vector and returns the offset along that vector at which the 1409 1409 minimum is determined. 1410 1410 … … 1713 1713 psFree(v); 1714 1714 min->iter = iterationNumber; 1715 // XXX: Ensure that currFuncVal is the correct value to use here. 1716 min->value = currFuncVal; 1715 1717 psTrace(".psLib.dataManip.psMinimizePowell", 4, 1716 1718 "---- psMinimizePowell() end (1)(true) ----\n"); … … 1749 1751 if (fabs(baseFuncVal - currFuncVal) <= min->tol) { 1750 1752 psFree(v); 1753 // XXX: Ensure that currFuncVal is the correct value to use here. 1754 min->value = currFuncVal; 1751 1755 min->iter = iterationNumber; 1752 1756 psTrace(".psLib.dataManip.psMinimizePowell", 4, -
trunk/psLib/src/math/psStats.c
r3540 r3547 9 9 * @author GLG, MHPCC 10 10 * 11 * @version $Revision: 1.12 2$ $Name: not supported by cvs2svn $12 * @date $Date: 2005-03-29 19:41:56$11 * @version $Revision: 1.123 $ $Name: not supported by cvs2svn $ 12 * @date $Date: 2005-03-29 22:34:59 $ 13 13 * 14 14 * Copyright 2004 Maui High Performance Computing Center, University of Hawaii … … 1489 1489 if (fabs(binSize) <= FLT_EPSILON) { 1490 1490 if (stats->options & PS_STAT_ROBUST_MEAN) { 1491 stats->robustMean = stats->clippedMean;1491 stats->robustMean = tmpStats->clippedMean; 1492 1492 } 1493 1493 if (stats->options & PS_STAT_ROBUST_MEDIAN) { 1494 stats->robustMedian = stats->clippedMean;1494 stats->robustMedian = tmpStats->clippedMean; 1495 1495 } 1496 1496 if (stats->options & PS_STAT_ROBUST_MODE) { 1497 stats->robustMode = stats->clippedMean;1497 stats->robustMode = tmpStats->clippedMean; 1498 1498 } 1499 1499 if (stats->options & PS_STAT_ROBUST_STDEV) { … … 1501 1501 } 1502 1502 if (stats->options & PS_STAT_ROBUST_QUARTILE) { 1503 stats->robustUQ = stats->clippedMean;1504 stats->robustLQ = stats->clippedMean;1503 stats->robustUQ = tmpStats->clippedMean; 1504 stats->robustLQ = tmpStats->clippedMean; 1505 1505 } 1506 1506 // XXX: Set these to the number of unmasked data points? … … 1512 1512 1513 1513 // Determine minimum and maximum values in the data vector. 1514 if (isnan( stats->min)) {1515 if (0 != p_psVectorMin(myVector, maskVector, maskVal, stats)) {1514 if (isnan(tmpStats->min)) { 1515 if (0 != p_psVectorMin(myVector, maskVector, maskVal, tmpStats)) { 1516 1516 psLogMsg(__func__, PS_LOG_WARN, 1517 1517 "WARNING: p_psVectorMin(): p_psVectorMin() reported a NAN mean.\n"); … … 1519 1519 } 1520 1520 } 1521 if (isnan( stats->max)) {1522 if (0 != p_psVectorMax(myVector, maskVector, maskVal, stats)) {1521 if (isnan(tmpStats->max)) { 1522 if (0 != p_psVectorMax(myVector, maskVector, maskVal, tmpStats)) { 1523 1523 psLogMsg(__func__, PS_LOG_WARN, 1524 1524 "WARNING: p_psVectorMin(): p_psVectorMax() reported a NAN mean.\n"); … … 1531 1531 // bins, not the binSize. Also, if we get here, we know that 1532 1532 // binSize != 0.0. 1533 numBins = (psS32)(( stats->max - stats->min) / binSize);1534 robustHistogram = psHistogramAlloc( stats->min, stats->max, numBins);1533 numBins = (psS32)((tmpStats->max - tmpStats->min) / binSize); 1534 robustHistogram = psHistogramAlloc(tmpStats->min, tmpStats->max, numBins); 1535 1535 1536 1536 // Populate the histogram array. … … 1620 1620 myStdev = PS_SQRT_F32((sumSquares - (sumDiffs * sumDiffs / countFloat)) / (countFloat - 1)); 1621 1621 1622 // Using the above (myMean, myStdev) as initial estimates, we fit a1623 // Gaussian to the robustHistogramVector.1624 psMinimization *min = psMinimizationAlloc(100, 0.1);1625 psVector *myParams = psVectorAlloc(2, PS_TYPE_F32);1626 psArray *myCoords = psArrayAlloc(robustHistogramVector->n);1627 psVector *y = psVectorAlloc(robustHistogramVector->n, PS_TYPE_F32);1628 1629 1622 p_psNormalizeVectorRangeF32(robustHistogramVector, 0.0, 1.0); 1630 for (i=0;i<robustHistogramVector->n;i++) { 1631 myCoords->data[i] = (psPtr *) psVectorAlloc(2, PS_TYPE_F32); 1632 ((psVector *) (myCoords->data[i]))->data.F32[0] = (psF32) i; 1633 y->data.F32[i] = robustHistogramVector->data.F32[i]; 1634 } 1635 1636 myParams->data.F32[0] = myMean; 1637 myParams->data.F32[1] = myStdev; 1638 psImage *covar = NULL; 1639 psMinimizeLMChi2(min, 1640 NULL, 1641 myParams, 1642 NULL, 1643 myCoords, 1644 y, 1645 NULL, 1646 (psMinimizeLMChi2Func) psMinimizeLMChi2Gauss1D); 1647 psFree(covar); 1648 psFree(min); 1649 psFree(myParams); 1650 psFree(myCoords); 1651 psFree(y); 1623 1624 if ((stats->options & PS_STAT_ROBUST_MEAN) || 1625 (stats->options & PS_STAT_ROBUST_STDEV)) { 1626 1627 // Using the above (myMean, myStdev) as initial estimates, we fit a 1628 // Gaussian to the robustHistogramVector. 1629 psImage *covar = NULL; 1630 psMinimization *min = psMinimizationAlloc(100, 0.1); 1631 psVector *myParams = psVectorAlloc(2, PS_TYPE_F32); 1632 psArray *myCoords = psArrayAlloc(robustHistogramVector->n); 1633 psVector *y = psVectorAlloc(robustHistogramVector->n, PS_TYPE_F32); 1634 1635 1636 myParams->data.F32[0] = myMean; 1637 myParams->data.F32[1] = myStdev; 1638 1639 /* XXX: old. Remove this. 1640 for (i=0;i<robustHistogramVector->n;i++) { 1641 myCoords->data[i] = (psPtr *) psVectorAlloc(2, PS_TYPE_F32); 1642 ((psVector *) (myCoords->data[i]))->data.F32[0] = (psF32) i; 1643 y->data.F32[i] = robustHistogramVector->data.F32[i]; 1644 } 1645 */ 1646 1647 for (i = modeBinNum - dL; i <= modeBinNum + dL; i++) { 1648 int index = i - modeBinNum + dL; 1649 myCoords->data[index] = (psPtr *) psVectorAlloc(2, PS_TYPE_F32); 1650 ((psVector *) (myCoords->data[index]))->data.F32[0] = PS_BIN_MIDPOINT(robustHistogram, i); 1651 y->data.F32[index] = robustHistogramVector->data.F32[i]; 1652 } 1653 1654 bool rc = psMinimizeLMChi2(min, 1655 NULL, 1656 myParams, 1657 NULL, 1658 myCoords, 1659 y, 1660 NULL, 1661 (psMinimizeLMChi2Func) psMinimizeLMChi2Gauss1D); 1662 if (rc == false) { 1663 psLogMsg(__func__, PS_LOG_WARN, 1664 "WARNING: failed to minimize with psMinimizeLMChi2().\n"); 1665 } 1666 1667 // XXX: Verify this with IfA 1668 // XXX: The check on the minimization is better than the difference from myMean. 1669 // Do they still want this code? 1670 1671 if (stats->options & PS_STAT_ROBUST_MEAN) { 1672 if (fabs((myParams->data.F32[0] - myMean)/myMean) > 0.1) { 1673 psLogMsg(__func__, PS_LOG_WARN, 1674 "WARNING: the fitted Gaussian has more than 10%% error for the mean.\n"); 1675 psLogMsg(__func__, PS_LOG_WARN, 1676 "WARNING: Using the calculated mean instead of Gaussian-fitted mean."); 1677 // "WARNING: Using the calculated mean instead of Gaussian-fitted mean.(calc, fit) is (%f, %f)\n", 1678 // myMean, myParams->data.F32[0]); 1679 stats->robustMean = myMean; 1680 } else { 1681 stats->robustMean = myParams->data.F32[0]; 1682 } 1683 } 1684 1685 1686 if (stats->options & PS_STAT_ROBUST_STDEV) { 1687 if (fabs((myParams->data.F32[1] - myStdev)/myStdev) > 0.1) { 1688 psLogMsg(__func__, PS_LOG_WARN, 1689 "WARNING: the fitted Gaussian has more than 10%% error for the stdev.\n"); 1690 psLogMsg(__func__, PS_LOG_WARN, 1691 "WARNING: Using the calculated stdev instead of Gaussian-fitted stdev."); 1692 // "WARNING: Using the calculated stdev instead of Gaussian-fitted stdev.(calc, fit) is (%f, %f)\n", 1693 // myStdev, myParams->data.F32[1]); 1694 stats->robustStdev = myStdev; 1695 } else { 1696 stats->robustStdev = myParams->data.F32[1]; 1697 } 1698 } 1699 psFree(covar); 1700 psFree(min); 1701 psFree(myCoords); 1702 psFree(y); 1703 psFree(myParams); 1704 } 1705 1706 1652 1707 /************************************************************************** 1653 1708 Set the appropriate members in the output stats struct. 1654 1709 **************************************************************************/ 1655 if (stats->options & PS_STAT_ROBUST_MEAN) {1656 if (fabs((myParams->data.F32[0] - myMean)/myMean) > 0.1) {1657 psLogMsg(__func__, PS_LOG_WARN,1658 "WARNING: the fitted Gaussian has more than 10%% error for the mean.\n");1659 psLogMsg(__func__, PS_LOG_WARN,1660 "WARNING: Using the calculated mean instead of Gaussian-fitted mean.");1661 // "WARNING: Using the calculated mean instead of Gaussian-fitted mean.(calc, fit) is (%f, %f)\n",1662 // myMean, myParams->data.F32[0]);1663 stats->robustMean = myMean;1664 } else {1665 stats->robustMean = myParams->data.F32[0];1666 }1667 }1668 1710 1669 1711 if (stats->options & PS_STAT_ROBUST_MODE) { … … 1671 1713 } 1672 1714 1673 if (stats->options & PS_STAT_ROBUST_STDEV) {1674 if (fabs((myParams->data.F32[1] - myStdev)/myStdev) > 0.1) {1675 psLogMsg(__func__, PS_LOG_WARN,1676 "WARNING: the fitted Gaussian has more than 10%% error for the stdev.\n");1677 psLogMsg(__func__, PS_LOG_WARN,1678 "WARNING: Using the calculated stdev instead of Gaussian-fitted stdev.");1679 // "WARNING: Using the calculated stdev instead of Gaussian-fitted stdev.(calc, fit) is (%f, %f)\n",1680 // myStdev, myParams->data.F32[1]);1681 stats->robustStdev = myStdev;1682 } else {1683 stats->robustStdev = myParams->data.F32[1];1684 }1685 }1686 1715 1687 1716 // To determine the median, we fit a quadratic y=f(x) to the three bins … … 2174 2203 *****************************************************************************/ 2175 2204 psStats* psVectorStats(psStats* stats, 2176 psVector* in,2177 psVector* errors,2178 psVector* mask,2205 const psVector* in, 2206 const psVector* errors, 2207 const psVector* mask, 2179 2208 psU32 maskVal) 2180 2209 { … … 2197 2226 inF32 = p_psConvertToF32((psVector *) in); 2198 2227 if (inF32 == NULL) { 2199 inF32 = in;2228 inF32 = (psVector *) in; 2200 2229 mustFreeVectorIn = 0; 2201 2230 } 2202 2231 errorsF32 = p_psConvertToF32((psVector *) errors); 2203 2232 if (errorsF32 == NULL) { 2204 errorsF32 = errors;2233 errorsF32 = (psVector *) errors; 2205 2234 mustFreeVectorErrors = 0; 2206 2235 } -
trunk/psLib/src/math/psStats.h
r3264 r3547 4 4 * @ingroup Stats 5 5 * 6 * This file will hold the definition of the histogram and stats data6 xd * This file will hold the definition of the histogram and stats data 7 7 * structures. It also contains prototypes for procedures which operate 8 8 * on those data structures. … … 10 10 * @author George Gusciora, MHPCC 11 11 * 12 * @version $Revision: 1. 39$ $Name: not supported by cvs2svn $13 * @date $Date: 2005-0 2-17 19:26:23$12 * @version $Revision: 1.40 $ $Name: not supported by cvs2svn $ 13 * @date $Date: 2005-03-29 22:34:59 $ 14 14 * 15 15 * Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii … … 87 87 psStats* psVectorStats( 88 88 psStats* stats, ///< stats structure defines stats to be calculated and how 89 psVector* in, ///< Vector to be analysed.90 psVector* errors, ///< Errors.91 psVector* mask, ///< Ignore elements where (maskVector & maskVal) != 0: must be INT or NULL89 const psVector* in, ///< Vector to be analysed. 90 const psVector* errors, ///< Errors. 91 const psVector* mask, ///< Ignore elements where (maskVector & maskVal) != 0: must be INT or NULL 92 92 psU32 maskVal ///< Only mask elements with one of these bits set in maskVector 93 93 );
Note:
See TracChangeset
for help on using the changeset viewer.
