PLearn 0.1
Public Member Functions | Static Public Member Functions | Static Public Attributes | Protected Member Functions | Static Protected Member Functions | Protected Attributes | Private Types | Private Member Functions | Private Attributes
PLearn::RemoveObservationTest Class Reference

The first sentence should be a BRIEF DESCRIPTION of what the class does. More...

#include <RemoveObservationTest.h>

Inheritance diagram for PLearn::RemoveObservationTest:
Inheritance graph
[legend]
Collaboration diagram for PLearn::RemoveObservationTest:
Collaboration graph
[legend]

List of all members.

Public Member Functions

 RemoveObservationTest ()
virtual string classname () const
virtual OptionListgetOptionList () const
virtual OptionMapgetOptionMap () const
virtual RemoteMethodMapgetRemoteMethodMap () const
virtual RemoveObservationTestdeepCopy (CopiesMap &copies) const
virtual void build ()
 Post-constructor.
virtual void makeDeepCopyFromShallowCopy (CopiesMap &copies)
 Transforms a shallow copy into a deep copy.
virtual void perform ()
 The method performing the test.

Static Public Member Functions

static string _classname_ ()
static OptionList_getOptionList_ ()
static RemoteMethodMap_getRemoteMethodMap_ ()
static Object_new_instance_for_typemap_ ()
static bool _isa_ (const Object *o)
static void _static_initialize_ ()
static const PPathdeclaringFile ()

Static Public Attributes

static StaticInitializer _static_initializer_

Protected Member Functions

bool compareCovariance (int t, const VecStatsCollector &batch, const VecStatsCollector &online)

Static Protected Member Functions

static bool compareStats (int t, const string &stat, const VecStatsCollector &batch, const VecStatsCollector &online)
static void declareOptions (OptionList &ol)
 Declares the class options.

Protected Attributes

VecStatsCollector m_windowed_vsc

Private Types

typedef PTest inherited

Private Member Functions

void build_ ()
 This does the actual building.

Private Attributes

Mat m_batch_cov
Mat m_online_cov

Detailed Description

The first sentence should be a BRIEF DESCRIPTION of what the class does.

Place the rest of the class programmer documentation here. Doxygen supports Javadoc-style comments. See http://www.doxygen.org/manual.html

Todo:
Write class to-do's here if there are any.
Deprecated:
Write deprecated stuff here if there is any. Indicate what else should be used instead.

Definition at line 58 of file RemoveObservationTest.h.


Member Typedef Documentation

Reimplemented from PLearn::PTest.

Definition at line 60 of file RemoveObservationTest.h.


Constructor & Destructor Documentation

PLearn::RemoveObservationTest::RemoveObservationTest ( )

Definition at line 55 of file RemoveObservationTest.cc.

{}

Member Function Documentation

string PLearn::RemoveObservationTest::_classname_ ( ) [static]

Reimplemented from PLearn::PTest.

Definition at line 50 of file RemoveObservationTest.cc.

OptionList & PLearn::RemoveObservationTest::_getOptionList_ ( ) [static]

Reimplemented from PLearn::PTest.

Definition at line 50 of file RemoveObservationTest.cc.

RemoteMethodMap & PLearn::RemoveObservationTest::_getRemoteMethodMap_ ( ) [static]

Reimplemented from PLearn::PTest.

Definition at line 50 of file RemoveObservationTest.cc.

bool PLearn::RemoveObservationTest::_isa_ ( const Object o) [static]

Reimplemented from PLearn::PTest.

Definition at line 50 of file RemoveObservationTest.cc.

Object * PLearn::RemoveObservationTest::_new_instance_for_typemap_ ( ) [static]

Reimplemented from PLearn::PTest.

Definition at line 50 of file RemoveObservationTest.cc.

StaticInitializer RemoveObservationTest::_static_initializer_ & PLearn::RemoveObservationTest::_static_initialize_ ( ) [static]

Reimplemented from PLearn::PTest.

Definition at line 50 of file RemoveObservationTest.cc.

void PLearn::RemoveObservationTest::build ( ) [virtual]

Post-constructor.

The normal implementation should call simply inherited::build(), then this class's build_(). This method should be callable again at later times, after modifying some option fields to change the "architecture" of the object.

Reimplemented from PLearn::PTest.

Definition at line 61 of file RemoveObservationTest.cc.

void PLearn::RemoveObservationTest::build_ ( ) [private]

This does the actual building.

Reimplemented from PLearn::PTest.

Definition at line 88 of file RemoveObservationTest.cc.

{
}
string PLearn::RemoveObservationTest::classname ( ) const [virtual]

Reimplemented from PLearn::PTest.

Definition at line 50 of file RemoveObservationTest.cc.

bool PLearn::RemoveObservationTest::compareCovariance ( int  t,
const VecStatsCollector batch,
const VecStatsCollector online 
) [protected]

Definition at line 116 of file RemoveObservationTest.cc.

References PLearn::endl(), PLearn::VecStatsCollector::getCovariance(), PLearn::VecStatsCollector::length(), and PLASSERT.

{
    PLASSERT(batch.length()==online.length());
    
    batch.getCovariance(m_batch_cov);
    online.getCovariance(m_online_cov);

    if ( !m_batch_cov.isEqual(m_online_cov, 5e-6) )
    {
        cerr << "At time " << t << " covariance differ!" << endl
             << "batch\n  " << m_batch_cov(0) << endl    
             << "online\n  " << m_online_cov(0) << endl << endl;
        return true;
    }
    return false;
}

Here is the call graph for this function:

bool PLearn::RemoveObservationTest::compareStats ( int  t,
const string &  stat,
const VecStatsCollector batch,
const VecStatsCollector online 
) [static, protected]

Definition at line 96 of file RemoveObservationTest.cc.

References PLearn::endl(), PLearn::VecStatsCollector::getAllStats(), PLearn::VecStatsCollector::length(), and PLASSERT.

{
    int len = batch.length();
    PLASSERT(len==online.length());
    
    Mat batch_stats(1, len, batch.getAllStats(stat));
    Mat online_stats(1, len, online.getAllStats(stat));

    if ( !batch_stats.isEqual(online_stats, 5e-6) )
    {
        cerr << "At time " << t << " " << stat << " differ: " << endl
             << "batch\n  " << batch_stats(0) << endl    
             << "online\n  " << online_stats(0) << endl << endl;
        return true;
    }
    return false;
}

Here is the call graph for this function:

void PLearn::RemoveObservationTest::declareOptions ( OptionList ol) [static, protected]

Declares the class options.

Reimplemented from PLearn::PTest.

Definition at line 79 of file RemoveObservationTest.cc.

{
    // Now call the parent class' declareOptions
    inherited::declareOptions(ol);
}
static const PPath& PLearn::RemoveObservationTest::declaringFile ( ) [inline, static]

Reimplemented from PLearn::PTest.

Definition at line 70 of file RemoveObservationTest.h.

:
    VecStatsCollector m_windowed_vsc;
RemoveObservationTest * PLearn::RemoveObservationTest::deepCopy ( CopiesMap copies) const [virtual]

Reimplemented from PLearn::PTest.

Definition at line 50 of file RemoveObservationTest.cc.

OptionList & PLearn::RemoveObservationTest::getOptionList ( ) const [virtual]

Reimplemented from PLearn::PTest.

Definition at line 50 of file RemoveObservationTest.cc.

OptionMap & PLearn::RemoveObservationTest::getOptionMap ( ) const [virtual]

Reimplemented from PLearn::PTest.

Definition at line 50 of file RemoveObservationTest.cc.

RemoteMethodMap & PLearn::RemoveObservationTest::getRemoteMethodMap ( ) const [virtual]

Reimplemented from PLearn::PTest.

Definition at line 50 of file RemoveObservationTest.cc.

void PLearn::RemoveObservationTest::makeDeepCopyFromShallowCopy ( CopiesMap copies) [virtual]

Transforms a shallow copy into a deep copy.

Reimplemented from PLearn::PTest.

Definition at line 70 of file RemoveObservationTest.cc.

References PLearn::deepCopyField().

Here is the call graph for this function:

void PLearn::RemoveObservationTest::perform ( ) [virtual]

The method performing the test.

A typical test consists in some output (to pout and / or perr), and updates of this object's options.

Reimplemented from PLearn::PTest.

Definition at line 137 of file RemoveObservationTest.cc.

References PLearn::VecStatsCollector::build(), PLearn::VecStatsCollector::compute_covariance, PLearn::VecStatsCollector::forget(), n, N, PLearn::VecStatsCollector::no_removal_warnings, PLearn::pow(), and PLearn::VecStatsCollector::update().

{
    int N = 8;
    int T = 2500;
    
    Vec obs(N);
    VecStatsCollector vsc;
    vsc.compute_covariance = true;
    vsc.no_removal_warnings = true;
    vsc.build();

    m_windowed_vsc.m_window = 100;
    m_windowed_vsc.compute_covariance = true;
    m_windowed_vsc.no_removal_warnings = true;
    m_windowed_vsc.build();

    for (int t=0; t<T; t++)
    {        
        int half_n = N/2;

        // Online window management
        for (int n=0; n<N; n++)
            obs[n] = (t+1) * pow(10.0, n-half_n);
        m_windowed_vsc.update(obs);

        // Batch window management
        vsc.forget();
        vsc.update(m_windowed_vsc.getObservations());

        bool stop =    compareStats(t, "N"          , vsc, m_windowed_vsc);
        stop = stop || compareStats(t, "NMISSING"   , vsc, m_windowed_vsc);
        stop = stop || compareStats(t, "NNONMISSING", vsc, m_windowed_vsc);
        stop = stop || compareStats(t, "E"          , vsc, m_windowed_vsc);
        stop = stop || compareStats(t, "V"          , vsc, m_windowed_vsc);
        stop = stop || compareStats(t, "STDDEV"     , vsc, m_windowed_vsc);
        stop = stop || compareStats(t, "STDERROR"   , vsc, m_windowed_vsc);
        stop = stop || compareStats(t, "SKEW"       , vsc, m_windowed_vsc);
        stop = stop || compareStats(t, "KURT"       , vsc, m_windowed_vsc);

        // Special covariance treatment
        stop = stop || compareCovariance(t, vsc, m_windowed_vsc);
        
        if( stop )
            break;
    }
        
    
    // cout << "E: " << vsc.getAllStats("E") << endl;
    // cout << "V: " << vsc.getAllStats("V") << endl;           
    // cout << "STDDEV: " << vsc.getAllStats("STDDEV") << endl;      
    // cout << "STDERROR: " << vsc.getAllStats("STDERROR") << endl;    
    // cout << "SKEW: " << vsc.getAllStats("SKEW") << endl;        
    // cout << "KURT: " << vsc.getAllStats("KURT") << endl;        
    // cout << "MIN: " << vsc.getAllStats("MIN") << endl;         
    // cout << "MAX: " << vsc.getAllStats("MAX") << endl;
    // cout << "RANGE: " << vsc.getAllStats("RANGE") << endl;       
    // cout << "SUM: " << vsc.getAllStats("SUM") << endl;         
    // cout << "SUMSQ: " << vsc.getAllStats("SUMSQ") << endl;       
    // cout << "FIRST: " << vsc.getAllStats("FIRST") << endl;       
    // cout << "LAST: " << vsc.getAllStats("LAST") << endl;        
    // cout << "N: " << vsc.getAllStats("N") << endl;           
    // cout << "NMISSING: " << vsc.getAllStats("NMISSING") << endl;    
    // cout << "NNONMISSING: " << vsc.getAllStats("NNONMISSING") << endl;        
}

Here is the call graph for this function:


Member Data Documentation

Reimplemented from PLearn::PTest.

Definition at line 70 of file RemoveObservationTest.h.

Definition at line 106 of file RemoveObservationTest.h.

Definition at line 107 of file RemoveObservationTest.h.

Definition at line 86 of file RemoveObservationTest.h.


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