Changeset 35617
- Timestamp:
- Jun 3, 2013, 8:40:02 AM (13 years ago)
- Location:
- branches/eam_branches/ipp-20130509/psLib
- Files:
-
- 4 edited
-
src/math/psMinimizeLMM.c (modified) (4 diffs)
-
src/math/psMinimizeLMM.h (modified) (1 diff)
-
test/math/Makefile.am (modified) (1 diff)
-
test/pstap/src/pstap.h (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
branches/eam_branches/ipp-20130509/psLib/src/math/psMinimizeLMM.c
r35615 r35617 325 325 chisq += PS_SQR(delta) * dy->data.F32[i]; 326 326 327 // XXX remove this later: 328 // psVector *tmp = x->data[i]; 329 // fprintf (stderr, "%f %f %f %f %f\n", tmp->data.F32[0], tmp->data.F32[1], y->data.F32[i], dy->data.F32[i], ymodel); 330 327 331 if (isnan(dy->data.F32[i])) goto escape; 328 332 if (isnan(delta)) goto escape; … … 716 720 } 717 721 722 // calculate the parameter change (rParDelta) and error radius (rParSigma) 723 // rParDelta : radius of parameter change; 724 // rParSigma : radius of parameter error 725 726 // note that (before SetABX) Alpha[i][i] is the covariance matrix and 727 // Beta is the actual parameter change for this pass 728 729 // note that Alpha & Beta only represent unmasked parameters 730 731 // dParSigma = Alpha[i][i] : error (squared) on parameter i 732 // dParDelta = Beta[i]^2 : change (squared) in parameter i 733 float rParSigma = 0.0; 734 for (int j = 0; j < Beta->n; j++) { 735 rParSigma += PS_SQR(Beta->data.F32[j]) / Alpha->data.F32[j][j]; 736 } 737 rParSigma = sqrt(rParSigma); 738 psTrace("psLib.math", 5, "rParSigma: %f, Niter: %d\n", rParSigma, min->iter); 739 718 740 // calculate Chisq for new guess, update Alpha & Beta 719 741 Chisq = psMinLM_SetABX(Alpha, Beta, Params, paramMask, x, y, dy, func); … … 744 766 min->lastDelta = (min->value - Chisq) / nDOF; 745 767 746 /* rho is positive if the new chisq is smaller; allow for some insignificant change (slight negative rho) */ 768 // rho is positive if the new chisq is smaller; allow for some insignificant change (slight negative rho) 769 // XXX : Madsen gives suggestion for better use of rho 747 770 if (rho >= -1e-6) { 748 771 min->value = Chisq; … … 766 789 } 767 790 768 // 3) require deltaChi > 1e-6 769 if (min->lastDelta < 1e-5) {791 // 3) require deltaChi > 1e-6 (ie, chisq is decreasing, but accept an insignificant change) 792 if (min->lastDelta < -1e-6) { 770 793 continue; 771 794 } 772 795 773 796 // 4) require rParDelta < \eta * rParSigma 774 // rParDelta : radius of parameter change; 775 // rParSigma : radius of parameter error 776 777 // note that alpha & beta only represent unmasked parameters 778 779 // R(Par_sigma) = \sum (alpha[i][i]) 780 float rParSigma = 0.0; 781 for (int j = 0; j < beta->n; j++) { 782 rParSigma += Alpha->data.F32[j][j]; 783 } 784 rParSigma = sqrt(rParSigma); 785 786 // note that beta or Beta is the actual parameter change for this pass : 787 // new param = old param - beta. I need to be sure I'm using the new 788 // or the old one and also the one before or after the matrix eqn Ax = B is solved. 789 float rParDelta = 0.0; 790 for (int j = 0; j < beta->n; j++) { 791 rParDelta += PS_SQR(lastBeta->data.F32[j] - Beta->data.F32[j]); 792 } 793 rParDelta = sqrt(rParDelta); 794 795 psTrace("psLib.math", 5, "rParDelta : %f, rParSigma: %f, Niter: %d\n", rParDelta, rParSigma, min->iter); 797 done |= (rParSigma < 0.01); 796 798 } 797 799 psTrace("psLib.math", 5, "chisq: %f, last delta: %f, Niter: %d\n", min->value, min->lastDelta, min->iter); -
branches/eam_branches/ipp-20130509/psLib/src/math/psMinimizeLMM.h
r28998 r35617 134 134 ); 135 135 136 /** Minimizes a specified function based on the Levenberg-Marquardt method 137 Uses alternative convergence criterion. 138 * 139 * @return bool: True if successful. 140 */ 141 bool psMinimizeLMChi2_Alt( 142 psMinimization *min, ///< Minimization specification 143 psImage *covar, ///< Covariance matrix 144 psVector *params, ///< "Best Guess" for the parameters that minimize func 145 psMinConstraint *constraint, ///< Constraints on the parameters 146 const psArray *x, ///< Measurement ordinates of multiple vectors 147 const psVector *y, ///< Measurement coordinates 148 const psVector *yWt, ///< Errors in the measurement coordinates 149 psMinimizeLMChi2Func func ///< Specified function 150 ); 151 136 152 bool psMinimizeGaussNewtonDelta ( 137 153 psVector *delta, -
branches/eam_branches/ipp-20130509/psLib/test/math/Makefile.am
r28998 r35617 48 48 tap_psMatrixVectorArithmetic04 \ 49 49 tap_psMinimizePowell \ 50 tap_psMinimizeLMM \ 51 tap_psMinimizeLMM_Alt \ 52 tap_psMinimizeLMM_Trail \ 50 53 tap_psSpline1D \ 51 54 tap_psPolynomialMD \ -
branches/eam_branches/ipp-20130509/psLib/test/pstap/src/pstap.h
r12738 r35617 144 144 } \ 145 145 } 146 147 # define ok_float is_float 148 # define ok_float_tol is_float_tol 149 # define ok_double is_double 150 # define ok_double_tol is_double_tol 151 # define ok_str is_str 152 # define ok_strn is_strn 153 # define ok_int is_int 154 # define ok_long is_long 155 # define ok_bool is_bool
Note:
See TracChangeset
for help on using the changeset viewer.
