Using EJML, is there a quick way to find mean of columns of a matrix?

336 Views Asked by At

Was looking for a function which returns a one diamensional SimpleMatrix giving the mean.

1

There are 1 best solutions below

0
On

Unfortunately there isn't a built in function to do that. This should do the trick though:

SimpleMatrix ones = new SimpleMatrix(1,10);
ones.set(1);
SimpleMatrix m = SimpleMatrix.random64(10,20,-1,2,new Random());

SimpleMatrix sum = ones.mult(m);
SimpleMatrix mean = sum.divide(10);