File:Regression cercle gruntz pathologique anim.gif

From Wikimedia Commons, the free media repository
Jump to navigation Jump to search

Original file(390 × 670 pixels, file size: 52 KB, MIME type: image/gif, looped, 38 frames, 19 s)

Captions

Captions

Add a one-line explanation of what this file represents

Summary[edit]

Description
English: Pathological case for the standard Gauss-Newton circle fitting: the point (3 ; 1) i close to the center of the model circle, which leads to a difficult convergence and a "weird looking" figure (although it is the correct total least squares model).
Français : Cas pathologique pour la régression circulaire utilisant la méthode de Gauss-Newton standard : le point (3 ; 1) est proche du centre du cercle modèle, cequi rend la convergence difficile, et donne une figure "bizarre" (bien qu'il s'agisse du modèle correct du point de vue des moindres carrés totaux).
Date
Source Own work
Coope, Ian D., Circle fitting by Linear and Nonlinear Least Squares, in "Journal of Optimization Theory and Applications", vol. 76, No. 2, pp. 381-388, february 1993
Gruntz, D., Finding the Best Fit Circle, in "The MathWorks Newsletter", Vol. 1, p. 5, 1990
http://groups.google.com/group/sci.math.num-analysis/msg/f936dad6ff285069
Author Cdang (Christophe Dang Ngoc Chan)

Scilab source

Code source similaire à File:Regression cercle gruntz anim.gif, mais avec un point de plus, et une condition plus robuste sur k.

// **********
// Initialisation
// **********

clear;

// données (D. Gruntz + I. D. Coope)

X0 = [0.7, 3.3, 5.6, 7.5, 6.4, 4.4, 0.3, -1.1, 3];
Y0 = [4.0, 4.7, 4.0, 1.3, -1.1, -3.0, -2.5, 1.3, 0.5];

// Paramètres de Newton-Raphson
precision = 1e-7; // condition d'arrêt
itermax = 60; // idem

Ainit = [3,0, 1] // cercle initial

// **********
// fonctions
// **********

function [ACx, ACy, AC] = caracteristiques(Xexp, Yexp, A)
    // calcule les caractéristiques du modèle
    // par rapport aux points expérimentaux
    // C(1) : xcentre (scalaire)
    // C(2) : ycentre (scalaire)
    // Xexp, Yexp : points mesurés (vecteur de nombres)
    // ACx : vecteur de composante x des vecteurs AC>
    // " y "
    // AC : longueurs des vecteurs AC>
    ACx = (A(1) - Xexp)';
    ACy = (A(2) - Yexp)';
    AC = ((ACx.^2 + ACy.^2).^(0.5));
endfunction

function [S] = residus(Xexp, Yexp, C)
    // Xexp, Yexp : coordonnées des points expérimentaux (vecteurs)
    // C : coordonnées du centre (vecteur)
    [ACx, ACy, AC] = caracteristiques(Xexp, Yexp, C);
    res = abs(C(3) - AC);
    S = sum(res);
endfunction

function []=affichage(X, Y, A, R, k)
    clf;
    subplot(2,1,1)
    plot2d(X, Y, style = -1) //, frameflag=4)
    isoview(-1.5, 7.5, -3.5, 5.5);
    xstring(-1.8, 5.3, 'C('+string(A(1))+' ; '+string(A(2))+') ; r = '+string(A(3)))
    // modèle
    plot(A(1), A(2), 'r+')
    diametre = 2*A(3);
    xarc(A(1) - A(3), A(2) + A(3),...
    diametre, diametre,...
    0, 360*64)
    a = get('hdl'); // ellipse
    a.foreground = 5; // couleur
    subplot(2,1,2)
    plot2d(R, rect=[1, 5, 38, 15])
    xstring(0.5, 0.1, 'α = '+string(k)+' ; R = '+string(R($)))
//    halt
endfunction

function [A, R]=regression_circulaire(Xexp, Yexp, Ainit, imax, epsilon)
    // Xexp, Yexp : points expérimentaux
    // A(1) : xcentre
    // A(2) : ycentre
    // A(3) : rayon
    // Ainit : valeur initiale de A
    // imax, epsilon : condition d'arrêt
    i = 1;
    k = 1;
    A = Ainit';
    dA = [1 1 1]';
    drapeau = %t; // pour la 1re itération
    R(1) = residus(Xexp, Yexp, A')
    affichage(Xexp, Yexp, Ainit, R, 1)
    disp('i = '+string(i)+' ; k = 1 ; R = '+string(R(i)))
    nom = 'cercle_gruntz_pathologique'+string(i)+'.png';
    xs2png(0,nom)
    while drapeau & (i <= imax)
        i = i+1;
        [ACx, ACy, AC] = caracteristiques(Xexp, Yexp, A);
        J = [ACx./AC, ACy./AC, -ones(ACx)]; // matrice des vecteurs unité
        f = -(AC - A(3)*(ones(Xexp))'); 
        dA = J\f;
        drapeau2 = %t // pour une 1re exécution
        while drapeau2 & (k>=0.1) // teste la divergence sur 1 étape
            A = A + k*dA; 
            R(i) = residus(Xexp, Yexp, A')
            drapeau2 = (R(i) >= R(i-1)) // vrai si diverge
            if drapeau2 then k = k*0.75; // atténue si diverge
                k0 = k; // pour affichage de la valeur
            else k0 = k; // pour affichage de la valeur
                k = (1 + k)/2; // réduit l'atténuation si converge
            end
        end
        if k < 0.1 then
            k = 0.1;
            k0 = k;
        end
        drapeau = (abs(R(i) - R(i-1)) > epsilon)
        disp('i = '+string(i)+' ; k = '+string(k0)+' ; R = '+string(R(i)))
        affichage(Xexp, Yexp, A', R, k0)
        nom = 'cercle_gruntz_pathologique'+string(i)+'.png';
        xs2png(0,nom)
    end
endfunction

// **********
// programme principal
// **********

// lecture des données

// Xdef, Ydef : vecteurs ligne

Xdef = X0;
Ydef = Y0;

fenetre = scf(0); // création de la fenêtre graphique
fenetre.figure_size = [400,800];

// regression
[Aopt, res] = regression_circulaire(Xdef, Ydef, Ainit, itermax, precision)
centre = Aopt(1:2);
rayon = Aopt(3);
R = res($);

print(%io(2), centre)
print(%io(2), rayon)
print(%io(2), R)

Licensing[edit]

I, the copyright holder of this work, hereby publish it under the following licenses:
GNU head Permission is granted to copy, distribute and/or modify this document under the terms of the GNU Free Documentation License, Version 1.2 or any later version published by the Free Software Foundation; with no Invariant Sections, no Front-Cover Texts, and no Back-Cover Texts. A copy of the license is included in the section entitled GNU Free Documentation License.
w:en:Creative Commons
attribution share alike
This file is licensed under the Creative Commons Attribution-Share Alike 3.0 Unported, 2.5 Generic, 2.0 Generic and 1.0 Generic license.
You are free:
  • to share – to copy, distribute and transmit the work
  • to remix – to adapt the work
Under the following conditions:
  • attribution – You must give appropriate credit, provide a link to the license, and indicate if changes were made. You may do so in any reasonable manner, but not in any way that suggests the licensor endorses you or your use.
  • share alike – If you remix, transform, or build upon the material, you must distribute your contributions under the same or compatible license as the original.
You may select the license of your choice.

File history

Click on a date/time to view the file as it appeared at that time.

Date/TimeThumbnailDimensionsUserComment
current13:59, 12 December 2012Thumbnail for version as of 13:59, 12 December 2012390 × 670 (52 KB)Cdang (talk | contribs){{Information |Description ={{en|1=Pathological case for the standard Gauss-Newton circle fitting: the point (3 ; 1) i close to the center of the model circle, which leads to a difficult convergence and a "weird looking" figure (although it is the c...

There are no pages that use this file.

File usage on other wikis

The following other wikis use this file:

Metadata