GURLS++  2.0.00
C++ Implementation of GURLS Matlab Toolbox
gurls::NormZScore< T > Class Template Reference

NormZScore is the sub-class of Norm that centers and rescales the input data matrix X.

#include <normzscore.h>

Inheritance diagram for gurls::NormZScore< T >:
Collaboration diagram for gurls::NormZScore< T >:

List of all members.

Public Member Functions

GurlsOptionsListexecute (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)

Detailed Description

template<typename T>
class gurls::NormZScore< T >

Definition at line 61 of file normzscore.h.


Member Function Documentation

template<typename T >
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

Parameters:
Xinput data matrix
Yinput data matrix
optnot used
Returns:
spheriphied input data matrix with mean and standard deviation

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;
}
template<typename T>
static Norm<T>* gurls::Norm< T >::factory ( const std::string &  id) throw (BadNormCreation) [inline, static, inherited]
Warning:
The returned pointer is a plain, un-managed pointer. The calling function is responsible of deallocating the object.

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);
    }

The documentation for this class was generated from the following file:
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Friends