0

Hello,

Quick question.. I'm trying to get the mean of a matrix (vector) now before I created a function that did it but I thought that it isn't really an effective way of coding. I've been looking at the accumulate function online and wanted to ask if this would work:

double Matrix1Mean = accumulate(matrix1.begin(),matrix1.end(),init)/(size_row*size_col);

Thanks :)

2
Contributors
1
Reply
2
Views
6 Years
Discussion Span
Last Post by Banfa
1

Should work fine but why not just divide by matrix1.size()?

Votes + Comments
Agree, infact he should generalize it into a CalculateMean function
This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.