Forums > Jitter

Averaging all the rows in a matrix

June 25, 2009 | 1:00 am

I would like to take a 2D matrix and get a vector out. Each element in the vector would be the average value of the corresponding column in the matrix. For a small example:

0 1 1
2 3 4
5 2 1

Would lead to:

7/3 2 2

It is relatively easy to do with jit.convolve and a kernel big enough to grab every value in a column, but that seems terribly inefficient. Is there a better way to do this?


June 25, 2009 | 3:00 am

way back when, I wrote an object for exactly this purpose called xray.jit.mean:

http://mat.ucsb.edu/whsmith/xray/xray.jit.mean.html

wes


June 25, 2009 | 4:15 am

Thank you, that is just what I needed!


Viewing 3 posts - 1 through 3 (of 3 total)