name: GaussianModel
synopsis:

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

>     #include <GaussianModel.h>

>     GaussianModel(MODE mode = DEF_MODE);
>     GaussianModel(const GaussianModel& arg);
>     boolean eq(const GaussianModel& arg) const;
>     boolean assign(const GaussianModel& arg);
>     boolean setMean(const VectorFloat& vec);
>     boolean setCovariance(const MatrixFloat& mat);

quick start:

>     GaussianModel gauss;
>     VectorFloat mean;
>     mean.assign(L"1.5, 2.5, 1.3");
>     gauss.setMean(mean);
>     MatrixFloat cov(3, 3, L"1.0, 2.0, 3.0", Integral::DIAGONAL);
>     gauss.setCovariance(cov);

description:
The GaussianModel class is used to calculate the likelihood of a vector modeled by a Gaussian probability density function. The density function is defined as follows:

|  | where |  |

The interface provides access to several variants of the calculation, including a log likelihood measure.
dependencies:

- VectorFloat
- MatrixFloat
- StatisticalModelBase
- MemoryManager

public constants:

- define the class name:

      static const String CLASS_NAME;

- define i/o related constants:

      static const String DEF_PARAM;

      static const String PARAM_MEAN;

      static const String PARAM_COVARIANCE;

      static const String PARAM_MEAN_ACCUM;

      static const String PARAM_COVARIANCE_ACCUM;

      static const String PARAM_OCCUPANCY_ACCUM;

      static const String PARAM_ACCESS_ACCUM;

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

      static const float DEF_SCALE_FACTOR = 0.0;

error codes:

- error code indicating GaussianModel class general error:

      static const long ERR = 60100;

protected data:

- mean accumulator vector:

      VectorDouble mean_accum_d;

- covariance accumulator matrix:

      MatrixDouble covar_accum_d;

- model access count accumulator:

      Long access_accum_d;

- model occupancy accumulator:

      Double occ_accum_d;

- mean vector:

      VectorFloat mean_d;

- covariance matrix:

      MatrixFloat covariance_d;

- density function scaling factor:

      float scale_d;

- a static scratch space for calculation involving the input vector and the distribution mean:

      static VectorFloat deviation_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);

- debug methods:

      boolean debug(const unichar* message) const;

  setDebug is inherited from base class

- destructor/constructor(s):

      ~GaussianModel();

      GaussianModel(MODE mode = DEF_MODE);

      GaussianModel(const GaussianModel& arg);

- assign methods:

      boolean assign(const GaussianModel& arg);

- operator= methods:

      GaussianModel& operator=(const GaussianModel& 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 readDataOccupancies(Sof& sof, const String& pname = DEF_PARAM, long size = SofParser::FULL_OBJECT, boolean param = true, boolean nested = false);

- equality methods:

      boolean eq(const GaussianModel& 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:

- constructor(s):

      GaussianModel(VectorFloat mean, MatrixFloat cov, MODE mode = DEF_MODE);

      GaussianModel(float mean, float variance, MODE mode = DEF_MODE);

- set methods:

      boolean setMean(const VectorFloat& mean);

      boolean setMean(float mean);

      boolean setCovariance(const MatrixFloat& cov);

      boolean setCovariance(float cov);

- get methods:

      boolean getMean(const VectorFloat& mean);

      boolean getMeanAccumulator(const VectorDouble& mean_accum);

      boolean getCovariance(const MatrixFloat& cov);

- interface contract for the StatisticalModelBase:

      boolean assign(const StatisticalModelBase& arg);

      boolean eq(const StatisticalModelBase& arg);

      boolean setMode(MODE mode);

      const String& className() const;

      boolean init();

      float getLikelihood(const VectorFloat& input);

      float getLogLikelihood(const VectorFloat& input);

- model reestimation methods:

      couble 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 adapt(const Vector<VectorFloat>& transform);

private methods:

- none

examples:

- This example shows how to set the GaussianModel and get the likelihood for a vector:

      // declare a GaussianModel object
      //
      GaussianModel model;

      // set the mean and covariance matrix
      //
      VectorFloat mean(L"1.0, 1.0, 1.0");
      MatrixFloat cov(3, 3, L"0.1, 0.1, 0.1", Integral::DIAGONAL);

      model.setMean(mean);
      model.setCovariance(cov);

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

      // get the log likelihood
      //
      Float distance = model.getLogLikelihood(input);

notes:

- none