import sympy


def antal_h_coefficient(index, game_matrix):
    """
    Returns the H_index coefficient, according to Antal et al. (2009), as given by equation 2.
    H_k = \frac{1}{n^2} \sum_{i=1}^{n} \sum_{j=1}^{n} (a_{kj}-a_{jj})
    Parameters
    ----------
    index: int
    game_matrix: sympy.Matrix
    
    Returns
    -------
    out: sympy.Expr
    
    
    Examples:
    --------
    >>>a = Symbol('a')
    >>>antal_h_coefficient(0, Matrix([[a,2,3],[4,5,6],[7,8,9]]))
    Out[1]: (2*a - 29)/9
    
    >>>antal_h_coefficient(0, Matrix([[1,2,3],[4,5,6],[7,8,9]]))
    Out[1]: -3
    """
    size = game_matrix.shape[0]
    suma = 0
    for i in range(0, size):
        for j in range(0, size):
            suma = suma + (game_matrix[index, i] - game_matrix[i, j])
    return sympy.together(sympy.simplify(suma / (size ** 2)), size)