[SciPy-User] How Can I Bin A Matrix?

David Cournapeau cournape@gmail....
Thu Oct 29 09:09:08 CDT 2009


On Thu, Oct 29, 2009 at 10:58 PM, Joseph Smidt <josephsmidt@gmail.com> wrote:
> Hello,
>
>     Lets pretend I have some random 100x100 matrix and I wanted to
> form a 10x10 matrix where each element of the 10x10 matrix is the
> average of the corresponding 10x10  block of the 100x100 matrix.

you could simply add submatrices for each item of a submatrix. To take
your example with 2x2 submatrices:

0.25 * (x[::2,::2] + x[1::2, ::2] + x[::2, 1::2] + x[1::2,1::2])

David


More information about the SciPy-User mailing list