Skip to content

Inefficient Gini Coefficient calculation? #855

@oliviaguest

Description

@oliviaguest

When I run:

gini_coef = pysal.inequality.gini.Gini(a).g

where a is any huge numpy array, e.g., with 300000 elements, it gets stuck, irreparably crashing my whole PC, trying to run this line of code (see here):

d = np.abs(np.array([x - xi for xi in x]))

This is not the case when I run it using my own code which does not make use of list comprehensions, and instead calculates Gini like this.
I wrote that just before I discovered you had a Gini function too, so I do not fully understand your code, although I am willing to help. The two functions produce very very similar output (indistinguishable before about 6 decimal places).

Anyway, I thought I would mention that it be worth considering using numpy to calculate the difference.

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions