If area += (height - wealth) / 2 is supposed to calculate the area under the Lorenz curve, it should just be area += height. If it's supposed to calculate the area between the line of equality and the Lorenz curve, then it doesn't work because the giniCoefficient = line treats it as the area under the Lorenz curve (among other reasons).
I can rework it to still calculate the area under the line of equality if you don't like the magic number 0.5, but it seems intuitive to normalize it.
The main problems were:
agent.wealth
(see my email)area += (height - wealth) / 2
is supposed to calculate the area under the Lorenz curve, it should just bearea += height
. If it's supposed to calculate the area between the line of equality and the Lorenz curve, then it doesn't work because theginiCoefficient =
line treats it as the area under the Lorenz curve (among other reasons).I can rework it to still calculate the area under the line of equality if you don't like the magic number 0.5, but it seems intuitive to normalize it.