IdentifiantMot de passe
Loading...
Mot de passe oublié ?Je m'inscris ! (gratuit)
Navigation

Inscrivez-vous gratuitement
pour pouvoir participer, suivre les réponses en temps réel, voter pour les messages, poser vos propres questions et recevoir la newsletter

MATLAB Discussion :

Comment faire fonctionner ce script sous Matlab R2007b


Sujet :

MATLAB

  1. #1
    Candidat au Club
    Homme Profil pro
    economie
    Inscrit en
    Novembre 2012
    Messages
    3
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : Maroc

    Informations professionnelles :
    Activité : economie
    Secteur : Enseignement

    Informations forums :
    Inscription : Novembre 2012
    Messages : 3
    Points : 3
    Points
    3
    Par défaut Comment faire fonctionner ce script sous Matlab R2007b
    Bonjour

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
    54
    55
    56
    57
    58
    59
    60
    61
    62
    63
    64
    65
    66
    67
    68
    69
    70
    71
    72
    73
    74
    75
    76
    77
    78
    79
    80
    81
    82
    83
    84
    85
    86
    87
    88
    89
    90
    91
    92
    93
    94
    95
    96
    97
    98
    99
    100
    101
    102
    103
    104
    105
    106
    107
    108
    109
    110
    111
    112
    113
    114
    115
    116
    117
    118
    119
    120
    121
    122
    123
    124
    125
    126
    127
    128
    129
    130
    131
    132
    % GINI computes the Gini coefficient and the Lorentz curve.
    %
    % Usage:
    %   g = gini(pop,val)
    %   [g,l] = gini(pop,val)
    %   [g,l,a] = gini(pop,val)
    %   ... = gini(pop,val,makeplot)
    %
    % Input and Output:
    %   pop     A vector of population sizes of the different classes.
    %   val     A vector of the measurement variable (e.g. income per capita)
    %           in the diffrerent classes.
    %   g       Gini coefficient.
    %   l       Lorentz curve: This is a two-column array, with the left
    %           column representing cumulative population shares of the
    %           different classes, sorted according to val, and the right
    %           column representing the cumulative value share that belongs to
    %           the population up to the given class. The Lorentz curve is a
    %           scatter plot of the left vs the right column.
    %   a       Same as l, except that the components are not normalized to
    %           range in the unit interval. Thus, the left column of a is the
    %           absolute cumulative population sizes of the classes, and the
    %           right colun is the absolute cumulative value of all classes up
    %           to the given one.
    %   makeplot  is a boolean, indicating whether a figure of the Lorentz
    %           curve should be produced or not. Default is false.
    %
    % Example:
    %   x = rand(100,1);
    %   y = rand(100,1);
    %   gini(x,y,true);             % random populations with random incomes
    %   figure;
    %   gini(x,ones(100,1),true);   % perfect equality
    %
    % Explanation:
    %
    %   The vectors pop and val must be equally long and must contain only
    %   positive values (zeros are also acceptable). A typical application
    %   would be that pop represents population sizes of some subgroups (e.g.
    %   different countries or states), and val represents the income per
    %   capita in this different subgroups. The Gini coefficient is a measure
    %   of how unequally income is distributed between these classes. A
    %   coefficient of zero means that all subgroups have exactly the same
    %   income per capital, so there is no dispesion of income; A very large
    %   coefficient would result if all the income accrues only to one subgroup
    %   and all the remaining groups have zero income. In the limit, when the
    %   total population size approaches infinity, but all the income accrues
    %   only to one individual, the Gini coefficient approaches unity.
    %
    %   The Lorenz curve is a graphical representation of the distribution. If
    %   (x,y) is a point on the Lorenz curve, then the poorest x-share of the
    %   population has the y-share of total income. By definition, (0,0) and
    %   (1,1) are points on the Lorentz curve (the poorest 0% have 0% of total
    %   income, and the poorest 100% [ie, everyone] have 100% of total income).
    %   Equal distribution implies that the Lorentz curve is the 45 degree
    %   line. Any inequality manifests itself as deviation of the Lorentz curve
    %   from the  45 degree line. By construction, the Lorenz curve is weakly
    %   convex and increasing.
    %
    %   The two concepts are related as follows: The Gini coefficient is twice
    %   the area between the 45 degree line and the Lorentz curve.
    %
    % Author : Yvan Lengwiler
    % Release: $1.0$
    % Date   : $2010-06-27$
     
    function [g,l,a] = gini(pop,val,makeplot)
     
        % check arguments
     
        assert(nargin >= 2, 'gini expects at least two arguments.')
     
        if nargin < 3
            makeplot = false;
        end
        assert(numel(pop) == numel(val), ...
            'gini expects two equally long vectors (%d ~= %d).', ...
            size(pop,1),size(val,1))
     
        pop = [0;pop(:)]; val = [0;val(:)];     % pre-append a zero
     
        isok = all(~isnan([pop,val]'))';        % filter out NaNs
        if sum(isok) < 2
            warning('gini:lacking_data','not enough data');
            g = NaN; l = NaN(1,4);
            return;
        end
        pop = pop(isok); val = val(isok);
     
        assert(all(pop>=0) && all(val>=0), ...
            'gini expects nonnegative vectors (neg elements in pop = %d, in val = %d).', ...
            sum(pop<0),sum(val<0))
     
        % process input
        z = val .* pop;
        [~,ord] = sort(val);
        pop    = pop(ord);     z    = z(ord);
        pop    = cumsum(pop);  z    = cumsum(z);
        relpop = pop/pop(end); relz = z/z(end);
     
        % Gini coefficient
     
        % We compute the area below the Lorentz curve. We do this by
        % computing the average of the left and right Riemann-like sums.
        % (I say Riemann-'like' because we evaluate not on a uniform grid, but
        % on the points given by the pop data).
        %
        % These are the two Rieman-like sums:
        %    leftsum  = sum(relz(1:end-1) .* diff(relpop));
        %    rightsum = sum(relz(2:end)   .* diff(relpop));
        % The Gini coefficient is one minus twice the average of leftsum and
        % rightsum. We can put all of this into one line.
        g = 1 - sum((relz(1:end-1)+relz(2:end)) .* diff(relpop));
     
        % Lorentz curve
        l = [relpop,relz];
        a = [pop,z];
        if makeplot   % ... plot it?
            area(relpop,relz,'FaceColor',[0.5,0.5,1.0]);    % the Lorentz curve
            hold on
            plot([0,1],[0,1],'--k');                        % 45 degree line
            axis tight      % ranges of abscissa and ordinate are by definition exactly [0,1]
            axis square     % both axes should be equally long
            set(gca,'XTick',get(gca,'YTick'))   % ensure equal ticking
            set(gca,'Layer','top');             % grid above the shaded area
            grid on;
            title(['\bfGini coefficient = ',num2str(g)]);
            xlabel('share of population');
            ylabel('share of value');
        end
     
    end
    le script permet normalement de calculer l'indice de gini mais je sais pas pourquoi j'obtiens plein d'erreurs
    je vous envoie le script m-files
    Fichiers attachés Fichiers attachés

  2. #2
    Membre éclairé
    Homme Profil pro
    Doctorant automatique
    Inscrit en
    Janvier 2012
    Messages
    446
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France, Bouches du Rhône (Provence Alpes Côte d'Azur)

    Informations professionnelles :
    Activité : Doctorant automatique
    Secteur : Aéronautique - Marine - Espace - Armement

    Informations forums :
    Inscription : Janvier 2012
    Messages : 446
    Points : 719
    Points
    719
    Par défaut
    Bonjour,

    Pour répondre à ta question "Comment faire fonctionner ce script sous Matlab R2007b", tu as trois possibilités, au choix :
    - soit tu apprends la programmation matlab
    - soit tu payes quelqu'un pour le faire à ta place
    - soit tu as de la chance et tu trouves une personne qui veut bien le faire à ta place gratuitement, mais si tu as une chance pareille, je te donne un conseil : laisse tomber le travail et vas jouer au loto

    Je te laisse choisir. Tiens nous au courant de ton avancée

    Cordialement,
    Je ne réponds pas aux MP techniques. Le forum est là pour ça.
    La raison est simple : il est ennuyeux de répondre à une seule personne, alors que la réponse peut servir à tout le monde.
    Conclusion : n'hésitez pas à utiliser le forum pour poser vos questions.
    Matlab 2005 - ver.7.1.0.183 (R14) Service Pack 3

  3. #3
    Modérateur

    Homme Profil pro
    Ingénieur en calculs scientifiques
    Inscrit en
    Août 2007
    Messages
    4 639
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : Royaume-Uni

    Informations professionnelles :
    Activité : Ingénieur en calculs scientifiques

    Informations forums :
    Inscription : Août 2007
    Messages : 4 639
    Points : 7 614
    Points
    7 614
    Par défaut
    Bonjour,

    Une autre solution, c'est que houssamonline nous indique le code utilisé ainsi que le message d'erreur complet obtenu afin que l'on puisse lui indiquer éventuellement un début de solution.

    A lire.
    Pour une bonne utilisation des balises code c'est ici!
    Petit guide du voyageur MATLABien : Le forum La faq Les tutoriels Les sources


    La nature est un livre écrit en langage mathématique. Galilée.

Discussions similaires

  1. Comment faire fonctionner la connec. web sous KVM
    Par TocTocKiéLà? dans le forum Virtualisation
    Réponses: 0
    Dernier message: 08/06/2010, 17h50
  2. Comment faire fonctionner ce script dans mon site ?
    Par beegees dans le forum jQuery
    Réponses: 4
    Dernier message: 02/01/2010, 23h01
  3. Comment faire fonctionner 2 webapp sous tomcat 5.5 ?
    Par rikunter dans le forum Tomcat et TomEE
    Réponses: 1
    Dernier message: 10/04/2008, 15h44
  4. Comment faire fonctionner le spell checker de FCKeditor sous firefox 2.0
    Par phpaide dans le forum Général JavaScript
    Réponses: 2
    Dernier message: 12/07/2007, 16h57
  5. [Chat] Comment faire fonctionner Flash 7 sous Debian ?
    Par piff62 dans le forum Evolutions du club
    Réponses: 22
    Dernier message: 07/03/2005, 15h27

Partager

Partager
  • Envoyer la discussion sur Viadeo
  • Envoyer la discussion sur Twitter
  • Envoyer la discussion sur Google
  • Envoyer la discussion sur Facebook
  • Envoyer la discussion sur Digg
  • Envoyer la discussion sur Delicious
  • Envoyer la discussion sur MySpace
  • Envoyer la discussion sur Yahoo