| 
    PLearn 0.1 
   | 
 
The first sentence should be a BRIEF DESCRIPTION of what the class does. More...
#include <RemoveObservationTest.h>


Public Member Functions | |
| RemoveObservationTest () | |
| virtual string | classname () const | 
| virtual OptionList & | getOptionList () const | 
| virtual OptionMap & | getOptionMap () const | 
| virtual RemoteMethodMap & | getRemoteMethodMap () const | 
| virtual RemoveObservationTest * | deepCopy (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 PPath & | declaringFile () | 
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 | 
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
Definition at line 58 of file RemoveObservationTest.h.
typedef PTest PLearn::RemoveObservationTest::inherited [private] | 
        
Reimplemented from PLearn::PTest.
Definition at line 60 of file RemoveObservationTest.h.
| PLearn::RemoveObservationTest::RemoveObservationTest | ( | ) | 
Definition at line 55 of file RemoveObservationTest.cc.
{}
| 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.
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.
{
    inherited::build();
    build_();
}
| 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;
}

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

| 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().
{
    deepCopyField(m_windowed_vsc, copies);
    inherited::makeDeepCopyFromShallowCopy(copies);
}

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

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.
 1.7.4