PLearn 0.1
Public Member Functions | Public Attributes | Static Public Attributes | Protected Attributes | Friends
PLearn::FieldStat Class Reference

#include <SDBWithStats.h>

Collaboration diagram for PLearn::FieldStat:
Collaboration graph
[legend]

List of all members.

Public Member Functions

int nsymbols ()
 FieldStat ()
int ntotal () const
int missing () const
int nonmissing () const
real mean () const
real stddev () const
real min () const
real max () const
void updateString (const string &sym)
void updateNumber (double d)
void updateMissing ()
void clear ()
 clear everything
void finalize ()
 computes final mean and stddev

Public Attributes

map< string, intsymbolcount
 For symbolic values.
map< string, intsymbolid
 an int between 1 and nsymbols associated to each symbol

Static Public Attributes

static int max_nsymbols = 400
 stop remembering symbols above this number...

Protected Attributes

int nonmissing_
 For all values:
int missing_
 number of entries with missing value
double sum_
 For numeric values:
double sumsquare_
double min_
double max_
double mean_
double stddev_

Friends

class SDBWithStats

Detailed Description

Definition at line 58 of file SDBWithStats.h.


Constructor & Destructor Documentation

PLearn::FieldStat::FieldStat ( ) [inline]

Definition at line 85 of file SDBWithStats.h.

        :nonmissing_(0), missing_(0), 
         sum_(0.), sumsquare_(0), min_(FLT_MAX), max_(-FLT_MAX)
    {}

Member Function Documentation

void PLearn::FieldStat::clear ( )

clear everything

Definition at line 72 of file SDBWithStats.cc.

Referenced by PLearn::SDBWithStats::forgetStats().

{
    nonmissing_ = 0;
    missing_ = 0; 
    sum_ = 0;
    sumsquare_ = 0;
    min_ = FLT_MAX;
    max_ = -FLT_MAX;
    mean_ = 0;
    stddev_ = 0;
    symbolcount.clear();
    symbolid.clear();
}

Here is the caller graph for this function:

void PLearn::FieldStat::finalize ( )

computes final mean and stddev

Definition at line 86 of file SDBWithStats.cc.

References PLearn::sqrt(), and PLearn::square().

{
    mean_ = sum_/nonmissing_;
    double meansquare_ = sumsquare_/nonmissing_;
    stddev_ = sqrt( meansquare_ - square(mean_) );
    if(nsymbols()>=max_nsymbols) // too many different values: ignore it (not really symbolic)
    {
        symbolcount.clear();
        symbolid.clear();
    }
}

Here is the call graph for this function:

real PLearn::FieldStat::max ( ) const [inline]

Definition at line 96 of file SDBWithStats.h.

Referenced by PLearn::SDBWithStats::saveStats().

{ return real(max_); }

Here is the caller graph for this function:

real PLearn::FieldStat::mean ( ) const [inline]

Definition at line 93 of file SDBWithStats.h.

Referenced by PLearn::SDBVMFieldNormalize::convertField(), and PLearn::SDBWithStats::saveStats().

{ return real(mean_); }

Here is the caller graph for this function:

real PLearn::FieldStat::min ( ) const [inline]

Definition at line 95 of file SDBWithStats.h.

Referenced by PLearn::SDBWithStats::saveStats().

{ return real(min_); }

Here is the caller graph for this function:

int PLearn::FieldStat::missing ( ) const [inline]

Definition at line 91 of file SDBWithStats.h.

Referenced by PLearn::SDBWithStats::saveStats().

{ return missing_; }

Here is the caller graph for this function:

int PLearn::FieldStat::nonmissing ( ) const [inline]

Definition at line 92 of file SDBWithStats.h.

Referenced by PLearn::SDBWithStats::saveStats().

{ return nonmissing_; }

Here is the caller graph for this function:

int PLearn::FieldStat::nsymbols ( ) [inline]

Definition at line 82 of file SDBWithStats.h.

Referenced by PLearn::SDBWithStats::saveStats().

{ return (int)symbolcount.size(); }

Here is the caller graph for this function:

int PLearn::FieldStat::ntotal ( ) const [inline]

Definition at line 90 of file SDBWithStats.h.

{ return missing_+nonmissing_; }
real PLearn::FieldStat::stddev ( ) const [inline]

Definition at line 94 of file SDBWithStats.h.

Referenced by PLearn::SDBVMFieldDivSigma::convertField(), PLearn::SDBVMFieldNormalize::convertField(), and PLearn::SDBWithStats::saveStats().

{ return real(stddev_); }

Here is the caller graph for this function:

void PLearn::FieldStat::updateMissing ( ) [inline]

Definition at line 100 of file SDBWithStats.h.

{ ++missing_; }
void PLearn::FieldStat::updateNumber ( double  d)

Definition at line 59 of file SDBWithStats.cc.

References d, and PLearn::tostring().

{
    ++nonmissing_;
    if(nsymbols()<max_nsymbols)
        symbolcount[tostring(d)]++;
    sum_ += d;
    sumsquare_ += d*d;
    if(d<min_)
        min_ = d;
    if(d>max_)
        max_ = d;
}

Here is the call graph for this function:

void PLearn::FieldStat::updateString ( const string &  sym)

Definition at line 52 of file SDBWithStats.cc.


Friends And Related Function Documentation

friend class SDBWithStats [friend]

Definition at line 60 of file SDBWithStats.h.


Member Data Documentation

double PLearn::FieldStat::max_ [protected]

Definition at line 73 of file SDBWithStats.h.

Referenced by PLearn::SDBWithStats::loadStats().

stop remembering symbols above this number...

Definition at line 83 of file SDBWithStats.h.

double PLearn::FieldStat::mean_ [protected]

Definition at line 74 of file SDBWithStats.h.

Referenced by PLearn::SDBWithStats::loadStats().

double PLearn::FieldStat::min_ [protected]

Definition at line 72 of file SDBWithStats.h.

Referenced by PLearn::SDBWithStats::loadStats().

number of entries with missing value

Definition at line 66 of file SDBWithStats.h.

Referenced by PLearn::SDBWithStats::loadStats().

For all values:

number of entries with non missing value

Definition at line 65 of file SDBWithStats.h.

Referenced by PLearn::SDBWithStats::loadStats().

double PLearn::FieldStat::stddev_ [protected]

Definition at line 75 of file SDBWithStats.h.

Referenced by PLearn::SDBWithStats::loadStats().

double PLearn::FieldStat::sum_ [protected]

For numeric values:

Definition at line 69 of file SDBWithStats.h.

double PLearn::FieldStat::sumsquare_ [protected]

Definition at line 70 of file SDBWithStats.h.

For symbolic values.

Definition at line 80 of file SDBWithStats.h.

Referenced by PLearn::SDBWithStats::loadStats(), and PLearn::SDBWithStats::saveStats().

map<string,int> PLearn::FieldStat::symbolid [mutable]

an int between 1 and nsymbols associated to each symbol

Definition at line 81 of file SDBWithStats.h.

Referenced by PLearn::SDBWithStats::loadStats(), PLearn::SDBVMFieldRemapReals::SDBVMFieldRemapReals(), and PLearn::SDBVMFieldRemapStrings::SDBVMFieldRemapStrings().


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