# Matrix of Matrices in Python [closed]

I want to create a matrix where each entry itself is a random matrix. What would be a good way to represent this?

It is not necessary but some hints on how to implement your proposed solution in Python would be useful.

What you are looking for is just a higher dimensional array.

Let's say you want a 5x5 array where each element is a 2x2 array with random number. You can easily represent that as a 5x5x2x2 array.

If you are happy about using numpy

A = numpy.random.rand(5,5,2,2)


Will create a 5x5x2x2 array.

You can use the first two indexes to access your 2D random arrays.

print A[1,1]


Results in:

[[ 0.68527006  0.37304491]
[ 0.23281899  0.46951261]]