inequality.theil.Theil¶
- class inequality.theil.Theil(y)[source]¶
Classic Theil measure of inequality.
\[T = \sum_{i=1}^n \left( \frac{y_i}{\sum_{i=1}^n y_i} \ln \left[ N \frac{y_i}{\sum_{i=1}^n y_i}\right] \right )\]- Parameters:
- y
numpy.array
An array in the shape \((n,t)\) or \((n,)\) with \(n\) taken as the observations across which inequality is calculated. If
y
is \((n,)\) then a scalar inequality value is determined. Ify
is \((n,t)\) then an array of inequality values are determined, one value for each column iny
.
- y
Notes
This computation involves natural logs. To prevent
ln[0]
from occurring, a small value is added to each element ofy
before beginning the computation.Examples
>>> import libpysal >>> import numpy >>> from inequality.theil import Theil
>>> f = libpysal.io.open(libpysal.examples.get_path('mexico.csv')) >>> vnames = [f'pcgdp{dec}' for dec in range(1940, 2010, 10)] >>> y = numpy.array([f.by_col[v] for v in vnames]).T >>> theil_y = Theil(y)
>>> theil_y.T array([0.20894344, 0.15222451, 0.10472941, 0.10194725, 0.09560113, 0.10511256, 0.10660832])
- Attributes:
- T
numpy.array
An array in the shape \((t,)\) or \((1,)\) containing Theil’s T for each column of
y
.
- T
Methods
__init__
(y)