I have an array that is 30x30 and inside each element is an array of 400 values.
Is there an easy way to take the standard deviation of the entire 'cube' or to recast it as a 30x30x400 cube?
In [295]: data.shape
Out[295]: (30, 30)
In [296]: data[0,0].shape
Out[296]: (400,)
Doing std(data) gives an array of the shape 400 so it does not apply it to the whole thing. And taking the std of the result is not the same.
Here is an example of such an array and how to make it.
a = np.zeros([3,3]).astype(object)
for i in range(3):
for j in range(3):
a[i,j] = np.array([0,i,j])
In [364]: a
Out[364]:
array([[array([0, 0, 0]), array([0, 0, 1]), array([0, 0, 2])],
[array([0, 1, 0]), array([0, 1, 1]), array([0, 1, 2])],
[array([0, 2, 0]), array([0, 2, 1]), array([0, 2, 2])]], dtype=object)
In [365]: a.shape
Out[365]: (3, 3)
In [366]: a[0,0]
Out[366]: array([0, 0, 0])
stdwould be simple usingnp.std.