IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 35617


Ignore:
Timestamp:
Jun 3, 2013, 8:40:02 AM (13 years ago)
Author:
eugene
Message:

new convergence criterion for LMM (in _Alt only for now)

Location:
branches/eam_branches/ipp-20130509/psLib
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • branches/eam_branches/ipp-20130509/psLib/src/math/psMinimizeLMM.c

    r35615 r35617  
    325325        chisq += PS_SQR(delta) * dy->data.F32[i];
    326326
     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
    327331        if (isnan(dy->data.F32[i])) goto escape;
    328332        if (isnan(delta)) goto escape;
     
    716720        }
    717721
     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
    718740        // calculate Chisq for new guess, update Alpha & Beta
    719741        Chisq = psMinLM_SetABX(Alpha, Beta, Params, paramMask, x, y, dy, func);
     
    744766        min->lastDelta = (min->value - Chisq) / nDOF;
    745767
    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
    747770        if (rho >= -1e-6) {
    748771            min->value = Chisq;
     
    766789        }
    767790
    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) {
    770793            continue;
    771794        }
    772795
    773796        // 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);
    796798    }
    797799    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  
    134134);
    135135
     136/** Minimizes a specified function based on the Levenberg-Marquardt method
     137    Uses alternative convergence criterion.
     138 *
     139 *  @return bool:   True if successful.
     140 */
     141bool 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
    136152bool psMinimizeGaussNewtonDelta (
    137153    psVector *delta,
  • branches/eam_branches/ipp-20130509/psLib/test/math/Makefile.am

    r28998 r35617  
    4848        tap_psMatrixVectorArithmetic04 \
    4949        tap_psMinimizePowell \
     50        tap_psMinimizeLMM \
     51        tap_psMinimizeLMM_Alt \
     52        tap_psMinimizeLMM_Trail \
    5053        tap_psSpline1D \
    5154        tap_psPolynomialMD \
  • branches/eam_branches/ipp-20130509/psLib/test/pstap/src/pstap.h

    r12738 r35617  
    144144    } \
    145145}
     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.