Calculates the average value of an observable
       it requires that states and operators have the same base

def expected_value(operator, eig_values, eig_states, beta):
    """Calculates the average value of an observable
       it requires that states and operators have the same base"""
    aux = np.einsum('i,ji,ji', np.exp(-beta*eig_values),
                    eig_states, operator.dot(eig_states))

    return aux / partition_func(beta, eig_values)