def lorenz(v):
    """
    Returns lorenz values to future plots
    Based on https://stackoverflow.com/questions/39512260/calculating-gini-coefficient-in-python-numpy
    """
    import numpy as np
    bins = np.linspace(0.0, 100.0, 11)
    total = float(np.sum(v))
    yvals = []
    for b in bins:
        bin_vals = v[v <= np.percentile(v, b)]
        bin_fraction = np.sum(bin_vals) / total * 100.0
        yvals.append(bin_fraction)
    pe_area = np.trapz(bins, x=bins)
    lorenz_area = np.trapz(yvals, x=bins)
    gini_val = (pe_area - lorenz_area) / float(pe_area)
    return bins, yvals, gini_val
