![]() |
GURLS++
2.0.00
C++ Implementation of GURLS Matlab Toolbox
|
NormZScore is the sub-class of Norm that centers and rescales the input data matrix X.
#include <normzscore.h>


Public Member Functions | |
| GurlsOptionsList * | execute (const gMat2D< T > &X, const gMat2D< T > &Y, const GurlsOptionsList &opt) throw (gException) |
| Normalizes the input data matrix X, centering them and rescaling it so that each dimension has std. | |
Static Public Member Functions | |
| static Norm< T > * | factory (const std::string &id) throw (BadNormCreation) |
| Factory function returning a pointer to the newly created object. | |
Protected Member Functions | |
| void | centerRescale (gMat2D< T > &M, T *stdDevs, const T *means) |
Definition at line 61 of file normzscore.h.
| GurlsOptionsList * gurls::NormZScore< T >::execute | ( | const gMat2D< T > & | X, |
| const gMat2D< T > & | Y, | ||
| const GurlsOptionsList & | opt | ||
| ) | throw (gException) [virtual] |
deviation 1. Then saves stats in a file with name root specified in the field name of opt
| X | input data matrix |
| Y | input data matrix |
| opt | not used |
Implements gurls::Norm< T >.
Definition at line 79 of file normzscore.h.
{
// [n,d] = size(X);
const unsigned long n = X.rows();
const unsigned long d = X.cols();
const unsigned long t = Y.cols();
// meanX = mean(X);
gMat2D<T> *v_meanX = new gMat2D<T>(1, d);
mean(X.getData(), v_meanX->getData(), n, d, d);
gMat2D<T> *v_meanY = new gMat2D<T>(1, t);
mean(Y.getData(), v_meanY->getData(), n, t, t);
// stdX = std(X) + eps;
// X = X - repmat(meanX, n, 1);
// X = X./repmat(stdX, n, 1);
gMat2D<T> *v_stdX = new gMat2D<T>(1, d);
gMat2D<T> *v_stdY = new gMat2D<T>(1, t);
gMat2D<T> *retX = new gMat2D<T>(n, d);
copy(retX->getData(), X.getData(), retX->getSize());
gMat2D<T> *retY = new gMat2D<T>(n, t);
copy(retY->getData(), Y.getData(), retY->getSize());
centerRescale(*retX, v_stdX->getData(), v_meanX->getData());
centerRescale(*retY, v_stdY->getData(), v_meanY->getData());
GurlsOptionsList* norm = new GurlsOptionsList("norm");
norm->addOpt("X", new OptMatrix<gMat2D<T> >(*retX));
norm->addOpt("meanX", new OptMatrix<gMat2D<T> >(*v_meanX));
norm->addOpt("stdX", new OptMatrix<gMat2D<T> >(*v_stdX));
norm->addOpt("Y", new OptMatrix<gMat2D<T> >(*retY));
norm->addOpt("meanY", new OptMatrix<gMat2D<T> >(*v_meanY));
norm->addOpt("stdY", new OptMatrix<gMat2D<T> >(*v_stdY));
return norm;
}
| static Norm<T>* gurls::Norm< T >::factory | ( | const std::string & | id | ) | throw (BadNormCreation) [inline, static, inherited] |
Definition at line 152 of file norm.h.
{
if(id == "l2")
return new NormL2<T>;
if(id == "zscore")
return new NormZScore<T>;
if(id == "testzscore")
return new NormTestZScore<T>;
throw BadNormCreation(id);
}