Drexel dragonThe Math ForumDonate to the Math Forum



Search All of the Math Forum:

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


Math Forum » Discussions » Software » comp.soft-sys.matlab

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

Advanced Search

Back to Topic List Back to Topic List Jump to Tree View Jump to Tree View   Messages: [ Previous | Next ]
jacob muller

Posts: 9
Registered: 11/24/05
Re: lorenz curve
Posted: Nov 30, 2005 8:50 AM
  Click to see the message monospaced in plain text Plain Text   Click to reply to this topic Reply

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



Point your RSS reader here for a feed of the latest messages in this topic.

[Privacy Policy] [Terms of Use]

© Drexel University 1994-2014. All Rights Reserved.
The Math Forum is a research and educational enterprise of the Drexel University School of Education.