name: StatisticalModel
synopsis:

>     g++ [flags ...] file ... -l /isip/tools/lib/$ISIP_BINARY/lib_stat.a

>     #include <StatisticalModel.h>

>     StatisticalModel(TYPE type = DEF_TYPE);
>     StatisticalModel(const StatisticalModel& arg);
>     boolean eq(const StatisticalModel& arg) const;
>     boolean assign(const StatisticalModel& arg);
>     boolean setMode(MODE mode);
>     MODE getMode() const;

quick start:

>     StatisticalModel model;
>     model.setMode(GAUSSAN_MODEL);

description:
The StatisticalModel class is used to evaluate the likelihood of an input vector with respect to a statistical model. This class provides a virtual interface to any class that implements the StatisticalModelBase interface contract.
dependencies:

- VectorFloat
- StatisticalModelBase
- StatisticalModelUndefined
- NameMap

public constants:

- define the class name:

      static const String CLASS_NAME = L"StatisticalModel";

- define the model types:

      enum TYPE { UNKNOWN = 0, GAUSSIAN_MODEL, MIXTURE_MODEL, UNIFORM_MODEL, SUPPORT_VECTOR_MODEL, RELEVANCE_VECTOR_MODEL, DEF_TYPE = UNKNOWN };

- define the algorithm choices:

      enum ALGORITHM { MIXTURE_SPLITTING = 0, DEF_ALGORITHM = MIXTURE_SPLITTING };

- define the implementation choices:

      enum IMPLEMENTATION { VARIANCE_SPLITTING = 0, DEF_IMPLEMENTATION = VARIANCE_SPLITTING };

- define i/o related constants:

      static const String StatisticalModel::DEF_PARAM = L"";

      static const String StatisticalModel::PARAM_TYPE = L"name";

- model type-related constants:

      static const NameMap TYPE_MAP = L"Undefined, GaussianModel, MixtureModel, UniformModel";

- define default value(s) of the class data:

      static const StatisticalModelUndefined NO_STAT_MODEL;

- define the perturb factor for splitting the models:

      static const float DEF_PERTURB_FACTOR = 0.2;

error codes:

- error code indicating StatisticalModel class general error:

      static const long ERR = 60300;

protected data:

- algorithm name:

      ALGORITHM algorithm_d;

- implementation name:

      IMPLEMENTATION implementation_d;

- virtual statistical model:

      StatisticalModelBase* virtual_model_d;

- define the memory manager:

      static MemoryManager mgr_d;

required public methods:

- static methods:

      static const String& name();

      static boolean diagnose(Integral::DEBUG debug_level);

      static boolean addModelToMixture(StatisticalModel& model_a, StatisticalModel& mixture_a);

- debug methods:

      boolean debug(const unichar* message) const;

  setDebug is inherited from base class

- destructor/constructor(s) methods:

      ~StatisticalModel();

      StatisticalModel(TYPE type = DEF_TYPE);

      StatisticalModel(const StatisticalModel& arg);

- assign methods:

      boolean assign(const StatisticalModel& arg);

- operator= methods:

      StatisticalModel& operator=(const StatisticalModel& arg);

- i/o methods:

      long sofSize() const;

      boolean read(Sof& sof, long tag, const String& name = CLASS_NAME);

      boolean write(Sof& sof, long tag, const String& name = CLASS_NAME) const;

      boolean readAccumulator(Sof& sof, long tag, const String& name = CLASS_NAME);

      boolean writeAccumulator(Sof& sof, long tag, const String& name = CLASS_NAME) const;

      boolean readData(Sof& sof, const String& pname = DEF_PARAM, long size = SofParser::FULL_OBJECT, boolean param = true, boolean nested = false);

      boolean writeData(Sof& sof, const String& pname = DEF_PARAM) const;

      boolean readAccumulatorData(Sof& sof, const String& pname = DEF_PARAM, long size = SofParser::FULL_OBJECT, boolean param = true, boolean nested = false);

      boolean writeAccumulatorData(Sof& sof, const String& pname = DEF_PARAM) const;

      boolean readOccupancies(Sof& sof, long tag, const String& name = CLASS_NAME);

      boolean readOccupanciesData(Sof& sof, const String& pname = DEF_PARAM, long size = SofParser::FULL_OBJECT, boolean param = true, boolean nested = false);

- equality methods:

      boolean eq(const StatisticalModel& arg) const;

- memory management methods:

      static void* operator new(size_t size);

      static void* operator new[](size_t size);

      static void operator delete(void* ptr);

      static void operator delete[](void* ptr);

      static boolean setGrowSize(long grow_size);

      boolean clear(Integral::CMODE cmode = Integral::DEF_CMODE);

class-specific public methods:

- additional methods needed to facilitate base class manipulations:

      ALGORITHM getAlgorithm();

      IMPLEMENTATION getImplementation();

      boolean setAlgorithm(ALGORITHM algorithm);

      boolean setImplementation(IMPLEMENTATION implementation);

      boolean setType(TYPE type);

      TYPE getType();

- constructor(s):

      StatisticalModel(const StatisticalModelBase& arg);

- interface contract for the StatisticalModelBase:

      boolean assign(const StatisticalModelBase& arg);

      boolean eq(const StatisticalModelBase& arg);

      boolean setMode(MODE mode);

      MODE getMode();

      const String& className() const;

      boolean init();

      boolean getMean(VectorFloat& mean;

      boolean getCovariance(MatrixFloat& cov);

      float getLikelihood(const VectorFloat& input);

      float getLogLikelihood(const VectorFloat& input);

      MixtureModel& getMixtureModel();

      GaussianModel& getGaussianModel();

      SupportVectorModel& getSupportVectorModel();

      RelevanceVectorModel& getRelevanceVectorModel();

      UniformModel& getUniformModel();

- model reestimation methods:

      double getOccupancy();

      boolean setOccupancy(double arg);

      boolean setAccessCount(long arg);

      long getAccessCount();

      boolean resetAccumulators();

      boolean initialize(VectorFloat& param);

      boolean accumulate(VectorFloat& param);

      boolean accumulate(VectorFloat& param, VectorFloat& data, boolean precomp);

      boolean update(VectorFloat& param);

      boolean splitMixtureModel(long arg);

private methods:

- none

examples:

- This example shows how to set the type of StatisticalModel and get the score:

      // declare the StatisticalModel object
      //
      StatisticalModel stat;

      // set the type of StatisticalModel
      //
      stat.setType(GAUSSIAN_MODEL);

      // declare a GaussianModel object
      //
      GaussianModel gauss;

      // declare mean and covariance matrix to define gaussian
      //
      VectorFloat mean(L"1.0, 1.0, 1.0");
      MatrixFloat cov(3, 3, L"0.1, 0.1, 0.1", Integral::DIAGONAL);

      // set gaussian
      //
      gauss.setMeans(mean);
      gauss.setCovariance(cov);

      // set the StatisticalModel obejct
      //
      stat.assign(gauss);

      // declare the input vector
      //
      VectorFloat input;
      input.assign(L"-1.050, -7.709, -2.303");

      // score the input vector
      //
      Float score = stat.getLogLikelihood(input);

notes:

- none