Registered Member
|
hello,
What would be the best way to do a feature normalize for an input MatrixXd X with Eigen? i.e. subtract the mean and divide by the variance column-wise. The pseudo code would be along the lines of e.g.
TIA, Best regards, Giovanni |
Moderator
|
For repmat you can use the replicate function, but here it is simpler to use rowwise. For coefficient-wise operations, you can either move to the array world or use the few cwise* functions. For instance:
|
Registered Member
|
hi ggael,
Thank you for the good and quick answer However, the results do not match Matlab, specifically computing the sample variance. In the example I proposed the variance should be [1 1 1] but with your proposed implementation results in [0.666667 0.666667 0.666667]. The issue is the unbiased sample variance formula. Using the unbiased sample variance then would be:
UPDATE: the feature normalization divides by the standard deviation and not by the variance. This has been corrected above. Best regards, Giovanni |
Registered users: Bing [Bot], Google [Bot], Yahoo [Bot]