Measure "uniform distribution" or "how equally distributed" is an amount represented with a group of numbers

152 Views Asked by At

To code a program I'm looking for an algorithm that returns 0 when a set is evenly distributed and 1 when it's totally "unfairly" distributed (or the other way around, it does not matter). For example:

Let's say there are 3 persons, each person has 2 dollars (so 6 dollars is the total amount of money). Suppose each element in the list represent the number of dollars that a particular person is given. Then, given the set:

[2, 2, 2]

the algorithm should return 0, because 6 it's 100% fairly distributed. However, if we instead give the algorithm the set:

[0, 6, 0]

it should return 1 because one person has all the money and the others have zero money, it's 100% unfair. As another example, the set:

[0, 5, 1]

it should return something like 0.85 (I'm guessing because I don't know how to calculate it)

Of course it should work with any amount of numbers.

I have zero knowledge of math so I really need your help. At least if you can guide me on the terms to search the web for this that would be great because I was not able to find anything useful.

1

There are 1 best solutions below

1
On BEST ANSWER

Perhaps one way of doing this would be to find the standard deviation of the set, and to then normalize it. The way to normalize it would be to find the maximum standard deviation for the set, and divide by it. The linked answer allows you to determine such a maximum value. Then, suppose you were to calculate the standard deviation $\sigma$ of your given set, and $\sigma_m$ is your maximum standard deviation. Then, $\sigma/\sigma_m$ would give you an indication of how "unfairly" the set is distributed.