Main Page | Namespace List | Class Hierarchy | Alphabetical List | Class List | File List | Namespace Members | Class Members | File Members

PLearn::VecStatsCollector Class Reference

#include <VecStatsCollector.h>

Inheritance diagram for PLearn::VecStatsCollector:

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

Collaboration graph
[legend]
List of all members.

Public Member Functions

 VecStatsCollector ()
int length () const
int size () const
virtual void build ()
 simply calls inherited::build() then build_()

virtual void forget ()
 clears all previously accumulated statistics

virtual void update (const Vec &x, real weight=1.0)
 updates the statistics when seeing x The weight applies to all elements of x

void setFieldNames (TVec< string > the_fieldnames)
 Declares names for the columns of the vector passed to update.

TVec< stringgetFieldNames () const
 Returns the declared names.

int getFieldNum (const string &fieldname_or_num) const
 Returns the index corresponding to a fieldname or to the fieldnum passed as a string.

virtual double getStat (const string &statspec)
 Returns a particular statistic.

void update (const Mat &m)
 calls update on all rows of m

void update (const Mat &m, const Vec &weights)
 calls update on all rows of m, with given weight vector

virtual void finalize ()
 finishes whatever computation are needed after all updates have been made

const StatsCollectorgetStats (int i) const
 returns statistics for element i

Vec getMean () const
 returns the empirical mean (sample average) vec

Vec getVariance () const
 returns the empirical variance vec

Vec getStdDev () const
 returns the empirical standard deviation vec

Vec getStdError () const
 returns the empirical standard deviation vec

const MatgetXtX () const
 returns uncentered covariance matrix (mean not subtracted X'.X)

Mat getCovariance () const
 returns centered covariance matrix (mean subtracted)

Mat getCorrelation () const
 returns correlation matrix

Vec getAllStats (Vec &st) const
 Fills vector st with [mean, variance, stddev, min, max] (after resizing it if it had a size of 0) However the order and number may change in future versions, so it's better to first call getIndexInAllStats to get the index of a given stat.

int getIndexInAllStats (int fieldindex, const string &statname) const
 Returns the index in the vector returned by getAllStats of the stat with the given name.

virtual void makeDeepCopyFromShallowCopy (map< const void *, void * > &copies)
 Transforms a shallow copy into a deep copy.

 PLEARN_DECLARE_OBJECT (VecStatsCollector)
 Declares name and deepCopy methods.


Public Attributes

int maxnvalues
 maximum number of different values to keep track of for each element

TVec< stringfieldnames
 (default: 0, meaning we only keep track of global statistics) names of the fields of the update vector

bool compute_covariance
 Should we compute and keep X'.X ?

TVec< StatsCollectorstats
 (default false)

Mat cov

Static Protected Member Functions

void declareOptions (OptionList &ol)
 Declares this class' options.


Private Types

typedef Object inherited

Private Member Functions

void build_ ()
 This does the actual building.


Member Typedef Documentation

typedef Object PLearn::VecStatsCollector::inherited [private]
 

Reimplemented from PLearn::Object.

Reimplemented in PLearn::LiftStatsCollector.

Definition at line 51 of file VecStatsCollector.h.


Constructor & Destructor Documentation

PLearn::VecStatsCollector::VecStatsCollector  ) 
 

Definition at line 46 of file VecStatsCollector.cc.


Member Function Documentation

void PLearn::VecStatsCollector::build  )  [virtual]
 

simply calls inherited::build() then build_()

Reimplemented from PLearn::Object.

Reimplemented in PLearn::LiftStatsCollector.

Definition at line 182 of file VecStatsCollector.cc.

References build_().

void PLearn::VecStatsCollector::build_  )  [private]
 

This does the actual building.

Reimplemented from PLearn::Object.

Reimplemented in PLearn::LiftStatsCollector.

Definition at line 179 of file VecStatsCollector.cc.

Referenced by build().

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

Declares this class' options.

Reimplemented from PLearn::Object.

Reimplemented in PLearn::LiftStatsCollector.

Definition at line 55 of file VecStatsCollector.cc.

References PLearn::declareOption(), and PLearn::OptionList.

void PLearn::VecStatsCollector::finalize  )  [virtual]
 

finishes whatever computation are needed after all updates have been made

Reimplemented in PLearn::LiftStatsCollector.

Definition at line 194 of file VecStatsCollector.cc.

References PLearn::TVec< StatsCollector >::size(), and stats.

Referenced by PLearn::computeStats().

void PLearn::VecStatsCollector::forget  )  [virtual]
 

clears all previously accumulated statistics

Reimplemented in PLearn::LiftStatsCollector.

Definition at line 188 of file VecStatsCollector.cc.

References cov, PLearn::TMat< T >::resize(), PLearn::TVec< StatsCollector >::resize(), and stats.

Referenced by PLearn::computeStats().

Vec PLearn::VecStatsCollector::getAllStats Vec st  )  const
 

Fills vector st with [mean, variance, stddev, min, max] (after resizing it if it had a size of 0) However the order and number may change in future versions, so it's better to first call getIndexInAllStats to get the index of a given stat.

Mat PLearn::VecStatsCollector::getCorrelation  )  const
 

returns correlation matrix

Definition at line 254 of file VecStatsCollector.cc.

References cov, PLearn::externalProduct(), getCovariance(), getStdDev(), PLearn::norm(), and PLearn::TMat< T >::width().

Mat PLearn::VecStatsCollector::getCovariance  )  const
 

returns centered covariance matrix (mean subtracted)

Definition at line 242 of file VecStatsCollector.cc.

References cov, PLearn::covariance(), getMean(), PLearn::TMat< T >::length(), stats, and PLearn::TMat< T >::width().

Referenced by getCorrelation().

TVec<string> PLearn::VecStatsCollector::getFieldNames  )  const [inline]
 

Returns the declared names.

Definition at line 111 of file VecStatsCollector.h.

References fieldnames.

int PLearn::VecStatsCollector::getFieldNum const string fieldname_or_num  )  const
 

Returns the index corresponding to a fieldname or to the fieldnum passed as a string.

returns -1 if not found

Definition at line 100 of file VecStatsCollector.cc.

References fieldnames, PLearn::TVec< string >::find(), PLearn::pl_isnumber(), and PLearn::toint().

Referenced by getStat().

int PLearn::VecStatsCollector::getIndexInAllStats int  fieldindex,
const string statname
const
 

Returns the index in the vector returned by getAllStats of the stat with the given name.

Currently available names are E (mean) V (variance) STDDEV MIN MAX Will throw an exception if statname is invalid

Vec PLearn::VecStatsCollector::getMean  )  const
 

returns the empirical mean (sample average) vec

Definition at line 202 of file VecStatsCollector.cc.

References k, PLearn::TVec< StatsCollector >::size(), and stats.

Referenced by getCovariance(), and PLearn::Experiment::run().

double PLearn::VecStatsCollector::getStat const string statspec  )  [virtual]
 

Returns a particular statistic.

Standard statistics specifications are of the form ex: STAT[fieldname] or STAT[fieldnum] where STAT is one of the statistics names understood by StatsCollector::getStat. fieldnum start at 0, and fieldnames must have been registered with setFieldNames. Subclasses may overload this to handle more exotic statistics than the few standard ones.

Reimplemented in PLearn::LiftStatsCollector.

Definition at line 80 of file VecStatsCollector.cc.

References getFieldNum(), PLearn::StatsCollector::getStat(), getStats(), PLearn::TVec< StatsCollector >::length(), MISSING_VALUE, PLERROR, PLearn::PStream::smartReadUntilNext(), and stats.

const StatsCollector& PLearn::VecStatsCollector::getStats int  i  )  const [inline]
 

returns statistics for element i

Definition at line 138 of file VecStatsCollector.h.

References getStats(), and stats.

Referenced by getStat(), and getStats().

Vec PLearn::VecStatsCollector::getStdDev  )  const
 

returns the empirical standard deviation vec

Definition at line 222 of file VecStatsCollector.cc.

References k, PLearn::TVec< StatsCollector >::size(), and stats.

Referenced by getCorrelation(), and PLearn::Experiment::run().

Vec PLearn::VecStatsCollector::getStdError  )  const
 

returns the empirical standard deviation vec

Definition at line 232 of file VecStatsCollector.cc.

References k, PLearn::TVec< StatsCollector >::size(), and stats.

Referenced by PLearn::Experiment::run().

Vec PLearn::VecStatsCollector::getVariance  )  const
 

returns the empirical variance vec

Definition at line 212 of file VecStatsCollector.cc.

References k, PLearn::TVec< StatsCollector >::size(), and stats.

const Mat& PLearn::VecStatsCollector::getXtX  )  const [inline]
 

returns uncentered covariance matrix (mean not subtracted X'.X)

Definition at line 154 of file VecStatsCollector.h.

References cov.

int PLearn::VecStatsCollector::length  )  const [inline]
 

Definition at line 93 of file VecStatsCollector.h.

References PLearn::TVec< StatsCollector >::length(), and stats.

Referenced by size().

void PLearn::VecStatsCollector::makeDeepCopyFromShallowCopy map< const void *, void * > &  copies  )  [virtual]
 

Transforms a shallow copy into a deep copy.

Reimplemented in PLearn::LiftStatsCollector.

Definition at line 261 of file VecStatsCollector.cc.

References PLearn::deepCopyField(), and stats.

PLearn::VecStatsCollector::PLEARN_DECLARE_OBJECT VecStatsCollector   ) 
 

Declares name and deepCopy methods.

void PLearn::VecStatsCollector::setFieldNames TVec< string the_fieldnames  )  [inline]
 

Declares names for the columns of the vector passed to update.

Definition at line 107 of file VecStatsCollector.h.

References fieldnames, and setFieldNames().

Referenced by PLearn::computeStats(), and setFieldNames().

int PLearn::VecStatsCollector::size  )  const [inline]
 

Definition at line 94 of file VecStatsCollector.h.

References length().

void PLearn::VecStatsCollector::update const Mat m,
const Vec weights
 

calls update on all rows of m, with given weight vector

Definition at line 168 of file VecStatsCollector.cc.

References PLearn::TMat< T >::length(), PLERROR, PLearn::TVec< T >::size(), and PLearn::update().

void PLearn::VecStatsCollector::update const Mat m  ) 
 

calls update on all rows of m

Definition at line 160 of file VecStatsCollector.cc.

References PLearn::TMat< T >::length(), and PLearn::update().

void PLearn::VecStatsCollector::update const Vec x,
real  weight = 1.0
[virtual]
 

updates the statistics when seeing x The weight applies to all elements of x

Reimplemented in PLearn::LiftStatsCollector.

Definition at line 116 of file VecStatsCollector.cc.

References compute_covariance, cov, PLearn::externalProductScaleAcc(), PLearn::TMat< T >::fill(), k, maxnvalues, PLERROR, PLearn::TMat< T >::resize(), PLearn::TVec< StatsCollector >::resize(), PLearn::TVec< StatsCollector >::size(), stats, PLearn::Vec, and x.

Referenced by PLearn::computeStats(), PLearn::GradientOptimizer::optimizeN(), PLearn::ConjGradientOptimizer::optimizeN(), PLearn::AdaptGradientOptimizer::optimizeN(), and PLearn::Experiment::run().


Member Data Documentation

bool PLearn::VecStatsCollector::compute_covariance
 

Should we compute and keep X'.X ?

Definition at line 65 of file VecStatsCollector.h.

Referenced by update().

Mat PLearn::VecStatsCollector::cov
 

Definition at line 69 of file VecStatsCollector.h.

Referenced by forget(), getCorrelation(), getCovariance(), getXtX(), and update().

TVec<string> PLearn::VecStatsCollector::fieldnames
 

(default: 0, meaning we only keep track of global statistics) names of the fields of the update vector

Definition at line 62 of file VecStatsCollector.h.

Referenced by getFieldNames(), getFieldNum(), and setFieldNames().

int PLearn::VecStatsCollector::maxnvalues
 

maximum number of different values to keep track of for each element

Definition at line 59 of file VecStatsCollector.h.

Referenced by update().

TVec<StatsCollector> PLearn::VecStatsCollector::stats
 

(default false)

Definition at line 68 of file VecStatsCollector.h.

Referenced by finalize(), forget(), getCovariance(), getMean(), getStat(), getStats(), getStdDev(), getStdError(), getVariance(), length(), makeDeepCopyFromShallowCopy(), and update().


The documentation for this class was generated from the following files:
Generated on Tue Aug 17 16:24:07 2004 for PLearn by doxygen 1.3.7