name: MixtureModel
synopsis:

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

>     #include <MixtureModel.h>

>     MixtureModel(MODE mode = DEF_MODE);
>     MixtureModel(const MixtureModel& arg);
>     boolean eq(const MixtureModel& arg) const;
>     boolean assign(const MixtureModel& arg);
>     boolean setWeights(const VectorFloat& arg);
>     boolean getWeights(VectorFloat& arg) const;
>     boolean normalizeWeights(float norm = DEF_NORM);
>     boolean add(StatisticalModelBase& ptr);

quick start:

>     MixtureModel model;
>     GaussianModel gauss;
>     UniformModel uniform;
>     VectorFloat weights(L"79, 5");
>     model.setWeights(weights);
>     model.add(gauss);
>     model.add(uniform);

description:
The MixtureModel class is used to score test vectors according to a distribution which is a linear combination of other StatisticalModels:

|  | where |  |

The mixture components can be any combination of other Statistical Model classes.
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_WEIGHTS;

      static const String PARAM_MODELS;

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

      static const float MIN_SCORE = -1e100;

- default arguments to methods:

      static const float DEF_NORM = 1.0;

error codes:

- error code indicating MixtureModel class general error:

      static const long ERR = 60200;

protected data:

- list of StatisticalModels:

      SingleLinkedList models_d;

- vector of weights:

      VectorFloat weights_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):

      ~MixtureModel();

      MixtureModel(MODE mode = DEF_MODE);

      MixtureModel(const MixtureModel& arg);

- assign methods:

      boolean assign(const MixtureModel& arg);

- operator= methods:

      MixtureModel& operator=(const MixtureModel& 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 MixtureModel& 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:

- set methods:

      boolean setModels(SingleLinkedList& new_models);

      boolean setWeights(const VectorFloat& arg);

- get methods:

      SingleLinkedList& getModels();

      VectorFloat& getDaWeights();

      boolean getWeights(VectorFloat& arg) const;

- methods to manipulate the models:

      boolean add(StatisticalModelBase& ptr);

- normalizatioin methods:

      boolean initializeWeights();

      boolean isNormalized(float norm = DEF_NORM) const;

      boolean normalizeWeights(float norm = DEF_NORM);

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

- mixture 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);

private methods:

- none

examples:

- This example shows how to set the MixtureModel and score a test vector:

      // declare the MixtureModel object
      //
      MixtureModel model;

      // declare GaussianModel and UniformModel objects
      //
      GaussianModel gauss;
      UniformModel uniform;

      // set the GaussianModel object
      //
      VectorFloat mean(L"1, 2, 3");
      MatrixFloat covar(3, 3, L"4, 5, 6", Integral::DIAGONAL);
      gauss.setMean(mean);
      gauss.setCovariance(covar);

      // set the UniformModel object
      //
      VectorFloat min(L"-1, -2, -3");
      VectorFloat max(L"1, 2, 3");
      uniform.setMin(min);
      uniform.setMax(max);

      // add model objects into the MixtureModel object
      //
      model.add(gauss);
      model.add(uniform);

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

      // score the input vector
      //
      Float score = model.getLikelihood(input);

notes:

- none