This forum has been archived. All content is frozen. Please use KDE Discuss instead.

computing mean an standard-deviation

Tags: None
(comma "," separated)
mdaakir
Registered Member
Posts
4
Karma
0

computing mean an standard-deviation

Sun Sep 29, 2013 12:28 pm
Hello,

I have one little problem using eigen.
I declare one matrix
Code: Select all
Eigen::MatrixXd coord(Eigen::DynamicIndex,3);

so with 3 columns. then I want to compute for each column the mean value and the standard deviation value.

I tried something like :
Code: Select all
float col_0_mean = coord.col(0).mean();

but seems not working. And I don't even know if a standard-deviation function exists.

Can you please give me a hand with this.

Thank you for your help
jitseniesen
Registered Member
Posts
204
Karma
2
You can use Eigen::Dynamic (and not Eigen::DynamicIndex; I did not even know that constant existed) as a template parameter, to indicate that the number of rows is not known at compile time but the number of columns is, as in
Code: Select all
Eigen::Matrix<double, Eigen::Dynamic, 3> coords;
The number of rows can then be specified later or in the same statement, for instance:
Code: Select all
Eigen::Matrix<double, Eigen::Dynamic, 3> coords(number_of_rows, 3);
// fill coords matrix
double col_0_mean = coord.col(0).mean();
I changed the type of col_0_mean to match the type of the matrix.

There is no function for computing the standard deviation, as far as I know.


Bookmarks



Who is online

Registered users: Bing [Bot], Google [Bot], Yahoo [Bot]