I have a matrix. I want to calculate the mean of each column and place these values into a vector. Is there a standard, simple way to do this? In fact, is there a way, generally, to run a function column-wise on a matrix? For example using Eigen I can calculate the mean of each column of MatrixXd m using this:
VectorXd means = m.colwise().mean();
Also, mean() can be replaced by other functions that operate on a vector and return a single value.
I'd love there to be something equally simple to use in dlib but I can't find it. I'd love to be able to pass in an arbitrary lambda as well as the reducing function.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
If you want to run a column wize function on a matrix I think the simplest
and most reasonable way is to just write a for loop. A function that
applied a lambda would just be a function with a for loop that called the
lambda.
I have a matrix. I want to calculate the mean of each column and place
these values into a vector. Is there a standard, simple way to do this?
In fact, is there a way, generally, to run a function column-wise on a
matrix? For example using Eigen I can calculate the mean of each column of
MatrixXd m using this:
VectorXd means = m.colwise().mean();
Also, mean() can be replaced by other functions that operate on a vector
and return a single value.
I'd love there to be something equally simple to use in dlib but I can't
find it. I'd love to be able to pass in an arbitrary lambda as well as the
reducing function.
Hello, bit of a newbie here I'm afraid!
I have a matrix. I want to calculate the mean of each column and place these values into a vector. Is there a standard, simple way to do this? In fact, is there a way, generally, to run a function column-wise on a matrix? For example using Eigen I can calculate the mean of each column of MatrixXd m using this:
VectorXd means = m.colwise().mean();
Also, mean() can be replaced by other functions that operate on a vector and return a single value.
I'd love there to be something equally simple to use in dlib but I can't find it. I'd love to be able to pass in an arbitrary lambda as well as the reducing function.
You can call sum_rows(m)/m.nr()
If you want to run a column wize function on a matrix I think the simplest
and most reasonable way is to just write a for loop. A function that
applied a lambda would just be a function with a for loop that called the
lambda.
On Wed, Aug 12, 2020 at 7:34 AM Matt Daley mbdaley@users.sourceforge.net
wrote:
Thanks for the reply. What you suggest sounds reasonable. I shall try that.