I have the following formula:
that i have to code (C is a mtrix, y and y_star are vectors). I tried the following, according to this post: Python numpy array sum over certain indices
> def chisq02(y, y_star, C_inv):
> indices = len(y)
> return np.sum(np.sum(np.matmul(y[i] - y_star[i], np.matmul(C_inv, y[j]-y_star[j])) for i in indices)for j in indices)
but it returns me the error:
TypeError: 'int' object is not iterable
Obviously it does not work... Does anyone know how this could work ?