Last active
July 22, 2023 00:15
-
-
Save kevinhughes27/6356673 to your computer and use it in GitHub Desktop.
Eigen3 Snips
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using namespace Eigen; | |
// these are the typedefs I like to work with | |
typedef Matrix< double, Dynamic, 1, ColMajor > EVector; | |
typedef Matrix< double, Dynamic, Dynamic, ColMajor > EMatrix; | |
// Mean | |
EVector mean = X.rowwise().sum() / X.rows(); | |
// Standard Deviation | |
EVector std = (X.rowwise() - mean.transpose()).array().pow(2).colwise().sum() / X.rows(); | |
// Mean Center | |
EMatrix Xc = X.colwise() - mean; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I think it's variance, not standard deviation, hence, it should be called
var
or a similar name.