Search All of the Math Forum:

Views expressed in these public forums are not endorsed by NCTM or The Math Forum.

Notice: We are no longer accepting new posts, but the forums will continue to be readable.

Topic: lorenz curve
Replies: 5   Last Post: May 13, 2013 7:38 AM

 Search Thread: Advanced Search

 Messages: [ Previous | Next ]
 Pardha Posts: 1 Registered: 5/13/13
Re: lorenz curve
Posted: May 13, 2013 7:38 AM
 Plain Text Reply

Hi Jacob,
How did you compute the gini coefficient from the plot/ code?

Thanks
Pardha
"jacob muller" <jacob@muller.com> wrote in message <ef1c97f.3@webx.raydaftYaTP>...
> hello Titus,
>
> the Lorenz function of matlab is not what i was looking for (but
> thanks anyway).
> I wanted an script to plot the lorenz curve and to compute the gini
> coefficient. Now i think that i managed thanks to the code posted by
> NZTideMan (THANKS!!)
> the script is looking like this:
>
> function [cumulative]=lorenz2dist(X,Y,plotting,plotvarx)
>
> % basic checkings
> if length(X)~=length(Y)
> error('vectors X and Y must have the same length')
> end
>
> % cumulation for the lorenz curve
> ratiodist=X./Y;
> % ranking based on the ratio
> [ratiosort, indexsort] =sort(ratiodist);
> % converting X and Y to percentage
> Xperce=X/sum(X)*100;
> Yperce=Y/sum(Y)*100;
> % sorting the distributions
> Xsort=Xperce([indexsort]);
> Ysort=Yperce([indexsort]);
> % Cumulative sum of sorted elements
> Xcumsum=cumsum(Xsort)
> Ycumsum=cumsum(Ysort)
> cumulative=[0 0; Xcumsum Ycumsum];
>
> switch plotting
> case 'yes'
> if plotvarx==1
> plotvary=2;
> else
> plotvary=1;
> end
> figure
> plot(cumulative(:,plotvarx), cumulative(:,plotvary),'*-')
> hold on
> plot(0:100,0:100,'k:')
> end

Date Subject Author
11/24/05 jacob muller
11/24/05 Roger Stafford
11/25/05 Derek Goring
11/25/05 Titus Edelhofer
11/30/05 jacob muller
5/13/13 Pardha

© The Math Forum at NCTM 1994-2018. All Rights Reserved.