In [1]:
examples_of_resources = [
    [5, 5, 5],
    [5, 10, 5],
    [5, 25, 5],
    [5, 40, 5],
    [0, 250, 0],
    [0, 2500, 0],
    [0, 25000000, 0],
    [0, 25000000, 0, 0],
    [0, 25000000, 0, 0, 0, 0, 0, 0, 0, 0],
]
\begin{equation*} J(x1,x2,...xn) = \frac{\left( \sum_{i=1}^{n} x_i \right)^2} {\left( n \sum_{i=1}^{n} x_i^2 \right)} \end{equation*}

In [2]:
def get_jain(resources):
    denom = 0
    nom = 0
    for r in resources:
        nom += r
        denom += r * r
    nom = nom * nom
    denom = len(resources) * denom
    return nom/denom

In [3]:
for example_of_resources in examples_of_resources :
    print(get_jain(example_of_resources))


1.0
0.8888888888888888
0.6049382716049383
0.5050505050505051
0.3333333333333333
0.3333333333333333
0.3333333333333333
0.25
0.1