Search All of the Math Forum:

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

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

 Messages: [ Previous | Next ]
 jacob muller Posts: 9 Registered: 11/24/05
Re: lorenz curve
Posted: Nov 30, 2005 8:50 AM

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