If you're using numpy
just do
np.mean(Y)
Also, it's good to add sample input and expected output data to your question.
If you want means for each t
you can do np.mean(np.mean(a, axis=0), axis=0)
, or as noted by @ophion you can shorten this to np.mean(a, axis=(0, 1))
in newer (1.71 and on) versions of NumPy.