IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

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)

File:
1 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);
Note: See TracChangeset for help on using the changeset viewer.