I need to have a more efficient code, that the one implemented by me below. Is it possible to have a more efficient code, also using numpy?
I am going to explain my algorithm and how it works. Considering the figure below, I have a matrix that contains 10000 matrix inside, and each matrix inside has a dimension 100x100.

My output should be a matrix 100x100, like this:
therefore, the first element of my "output" V[f(a_1,b_1)] is the variance of all f(a_1,b_1) elements contained in 10000 matrices. Thus, I need to compute the variances of the elements with the same index.
Below there is the code used, it should be correct (I hope..). is it possible to have a more efficient code? (for simplicity, I simulate the input with random numbers, since the matrix is too big to post here)
import numpy as np
input = np.random.randint(0, 100, size=(10000, 100, 100))
output = []
for n in range(100):
row = []
for i in range(100):
row2 = []
for m in range(10000):
P_mi_sigmai = input[m][n][i]
row2.append(P_mi_sigmai)
variance = np.var(row2)
row.append(variance)
output.append(row)
print(np.array(output).shape)
