function l = lorenzc(x)

// Lorenz curve

// x ... data vector
// l ... values for Lorenz curve construction

// Literature: Basmann, R.L., Hayes, K.J., Slottje,
// D.J. (1993). Some new methods for measuring
// and describing economic inequality, JAI Press:
// Connecticut

// Copyright (C): Lukáš Malec and Jaroslav Poživil;
// University of Business in Prague, Czech Republic
// Date: $2014-02-01$

if x==[] then l=%nan, return, end

n = length(x), x = matrix(x,n,1)
x = gsort(x,'r','i')

eq(1:n,1) = 1, eq = cumsum(eq)
eq = eq/max(eq)

v = cumsum(x), v = v/max(v)

eq = [0;eq(:)], v = [0;v(:)]

l = [eq,v]

plot(eq,v,3)
xfpoly([eq;1],[v;0],19)

plot([0,1],[0,1],'-.k')
set(gca(),'tight_limits',"on")

set(gca(),"grid",[1,1])

xlabel("cumulative share of population")
ylabel("cumulative share of value")

endfunction
