# Balance inequality
See also 'zero crossing frequency' under [circularity of trade](/CMlnVwUjR6-EPA4jHyqsqw) and [balance vector](/RK0pk9ncTfOugxtb22ZiyA).
One way of estimating the inequality between balances within a club $C_j$ is to look at the magnitudes of the pairwise differences, i.e. calculate the difference between the balances of $M_1$ and $M_2$, $M_1$ and $M_3$... and add up the total to get the sum of absolute pairwise differences:
$$\frac{\sum_{i=1}^N\sum_{l=1}^N|b_{M_i}-b_{M_e}|}{2}.
$$
The factor of two corrects for the double-counting in the summation (i.e. including $|M_1-M_2|$ and $|M_2-M_1|$). This can then be normalised to the total number of pairs given by $N^2/2$ (the way that the summation is defined means that a comparison of a member with itself is a valid pair, so the factor of $N$ does not need to be subtracted as it is in [Metcalfe's law](https://en.wikipedia.org/wiki/Metcalfe's_law)). This does necessarily mean that a trading relationship exists between all pairs; it simply gives the average absolute pairwise difference between balances. A further normalisation to the average of all $N^+$ positive balances $b_{M_i}^+$ and introducing a factor of two in the denominator to shift the values such that they range from zero to one gives:
$$\frac{\sum_{i=1}^N\sum_{l=1}^N|b_{M_i}-b_{M_e}|}{2\times N^2\times \overline{b_{M_i}^+}},
$$
where
$$ \overline{b_{M_i}^+}= \frac{\sum_{i=1}^{N^+}b_{M_i}^+}{N^+}.
$$
This is the same as the [Gini coefficient](https://en.wikipedia.org/wiki/Gini_coefficient), except that the summation in the numerator can include negative values and scale-independence is based on an average over a subset of all balances (multiply by two since with zero BoT total +ve = total -ve?). This is primarily because in a club with zero [balance of trade](/e0Z2fSQdSYmzIlsVzNknNg) $b_{C_j}$ the mean of all account balances will always be zero, but also because $b_{C_j} <$ 0 would result in a negative coefficient, which is not easy to interpret (when calculating the Gini coefficient all incomes are assumed to be positive or zero - see [here](http://siba-ese.unisalento.it/index.php/ejasa/article/view/19223)).
There is an extensive literature on the limitations of the Gini coefficient, but thinking more about the properties of this variant is probably necessary to understand to what extent the results apply.
As per the discussion with respect to the zero crossing frequency $F$ as an element of [circularity](/CMlnVwUjR6-EPA4jHyqsqw?both), the sum of all balances is always equal to the balance of trade $b_{C_j}$, so if this is non-zero then $\overline{b_{M_i}^+}$ will correlate with the retention $R$ (since this latter is in turn correlated with the balance of trade). Specifically, a running net surplus of credit will tend to increase $\overline{b_{M_i}^+}$, reducing the coefficient, whilst a running deficit will tend to reduce $\overline{b_{M_i}^+}$ and therefore increase it. Since there is no reason to link a non-zero balance of trade (corresponding to inequality between clubs) with inequality within clubs this correlation should be eliminated as far as possible by subtracting $b_{C_j}/N$ from $\overline{b_{M_i}^+}$.
Finally, in keeping with the convention established for the circularity metric that one corresponds to good and zero to bad, the equality index $E$ is defined:
$$E = 1- \frac{\sum_{i=1}^N\sum_{l=1}^N|b_{M_i}-b_{M_e}|}{2 \times N^2 \times (\overline{b_{M_i}^+}- \frac{b_{C_j}}{N})},
$$
such that a value close to zero implies a high degree of inequality. Note that turnover is not included in this calculation - this is a separate variable of more relevance to individual [account health](/xnUSdbbaQS-wn0KmIYRh-Q). Some examples:
```vega
{
"$schema": "https://vega.github.io/schema/vega-lite/v4.json",
"description": "Inequality examples",
"data": {
"values": [
{"Example": "1", "Member": 1, "Balance": -30},
{"Example": "1", "Member": 2, "Balance": -70},
{"Example": "1", "Member": 3, "Balance": 25},
{"Example": "1", "Member": 4, "Balance": 20},
{"Example": "1", "Member": 5, "Balance": 1080},
{"Example": "1", "Member": 6, "Balance": -30},
{"Example": "1", "Member": 7, "Balance": -56},
{"Example": "1", "Member": 8, "Balance": 22},
{"Example": "1", "Member": 9, "Balance": 20},
{"Example": "1", "Member": 10, "Balance": -981},
{"Example": "2", "Member": 1, "Balance": -70},
{"Example": "2", "Member": 2, "Balance": 22},
{"Example": "2", "Member": 3, "Balance": 25},
{"Example": "2", "Member": 4, "Balance": -281},
{"Example": "2", "Member": 5, "Balance": 1080},
{"Example": "2", "Member": 6, "Balance": -30},
{"Example": "2", "Member": 7, "Balance": -281},
{"Example": "2", "Member": 8, "Balance": 20},
{"Example": "2", "Member": 9, "Balance": 20},
{"Example": "2", "Member": 10, "Balance": -505},
{"Example": "3", "Member": 1, "Balance": 20},
{"Example": "3", "Member": 2, "Balance": 22},
{"Example": "3", "Member": 3, "Balance": 25},
{"Example": "3", "Member": 4, "Balance": -242},
{"Example": "3", "Member": 5, "Balance": 1080},
{"Example": "3", "Member": 6, "Balance": -270},
{"Example": "3", "Member": 7, "Balance": 20},
{"Example": "3", "Member": 8, "Balance": -130},
{"Example": "3", "Member": 9, "Balance": -230},
{"Example": "3", "Member": 10, "Balance": -295},
{"Example": "4", "Member": 1, "Balance": 20},
{"Example": "4", "Member": 2, "Balance": -115},
{"Example": "4", "Member": 3, "Balance": -156},
{"Example": "4", "Member": 4, "Balance": 173},
{"Example": "4", "Member": 5, "Balance": 322},
{"Example": "4", "Member": 6, "Balance": 402},
{"Example": "4", "Member": 7, "Balance": -482},
{"Example": "4", "Member": 8, "Balance": -369},
{"Example": "4", "Member": 9, "Balance": 250},
{"Example": "4", "Member": 10, "Balance": -45}
]
},
"mark": "bar",
"encoding": {
"column": {"field": "Example", "type": "ordinal", "spacing": 5},
"x": {"field": "Member", "type": "ordinal"},
"y": {"field": "Balance", "type": "quantitative"}
}
}
```
In all cases the sum of all positive balances equals the sum of all negative balances (implying $b_{C_j}=$ 0) at 1167 units, and there are five accounts with positive balances and five with negative balances. In the first case one account has an extremely large positive balance (which remains unchanged for the next two examples), another has an extremely large negative balance and the others hover around zero. In the second, three accounts have large negative balances whilst the others stay around zero, and total negative is shared more evenly still in the third. In the final example there are no outliers. The values of $E$ are 0.151, 0.218, 0.286 and 0.325; as the distributions become more even, the equality index increases.
In the ideal case of perfect equality (all balances ending at zero), both the numerator and denominator are zero. Setting aside arguments about what that actually means and assuming it comes to zero results in $E=$ 1.
### Further work
If one account has a balance of $b$, another has a balance of $-b$ and all the rest are zero then the equality index depends entirely on $N$; for $N=$ 10, $E=$ 0.820 and for $N=$ 20, $E=$ 0.905. This applies for all $b$, including $b=$ 1 where by common sense equality is almost perfect and for any arbitrarily large value where inequality is very high. In practice the balance of almost every active member reaching zero seems unlikely, but this should be investigated further.
A complementary approach may be to consider the ratio of total credit to total debit for the 20% of active members who are closest to their positive and negative balance limits. This recognises that accounts near their limits are the most significant and is sometimes used to address limitations of the Gini coefficient.
### More articles
* [Gini's mean difference in the theory and application to inflated distributions](https://www.researchgate.net/publication/265654233_Gini%27s_mean_difference_in_the_theory_and_application_to_inflated_distributions/fulltext/54aa43870cf256bf8bb96828/Ginis-mean-difference-in-the-theory-and-application-to-inflated-distributions.pdf)
* [Gini's Mean Difference: A Superior Measure of Variability for Non-Normal Distributions](https://www.researchgate.net/publication/5182211_Gini%27s_Mean_Difference_A_Superior_Measure_of_Variability_for_Non-Normal_Distributions)
* [Income inequality metrics](https://en.wikipedia.org/wiki/Income_inequality_metrics)
* [More Than a Dozen Alternative Ways of Spelling Gini](https://www.researchgate.net/publication/228706719_More_Than_a_Dozen_Alternative_Ways_of_Spelling_Gini)
* [Diversity index](https://en.wikipedia.org/wiki/Diversity_index)
* [Wealth condensation in a simple model of economy](https://arxiv.org/abs/cond-mat/0002374)