Skip to content

Instantly share code, notes, and snippets.

@odinokov
odinokov / gini.py
Last active December 5, 2022 16:59
An efficient way to calculate weighted Gini coefficient in Python
import numba
import numpy as np
@numba.jit
def gini(x, w=None):
# from https://stackoverflow.com/questions/48999542/more-efficient-weighted-gini-coefficient-in-python
# The rest of the code requires numpy arrays.
# x = np.asarray(x)
if w is not None:
# w = np.asarray(w)