Library Name: lib_stat.a

Introduction:

The ISIP Foundation Classes (IFCs) include statistical model classes to evaluate the likelihood of an input vector with respect to a statistical model. Two basic statistical models: GaussianModel and UniformModel are provided. MixtureModel, which is a linear combination of any statistical model class is also provided to facilitate creation of complex statistical models such as mixture distributions.
Example:
Let's begin with a simple example:
```01  // file: \$isip/doc/examples/class/stat/stat_example_00/example.cc
02  // version: \$Id: index.html 10251 2005-09-16 19:14:10Z srinivas \$
03  //
04
05  // isip include files
06  //
07  #include <GaussianModel.h>
08
09  // main program starts here:
10  //  this example demonstrates the several simple steps to compute the
11  //  Mahalanobis distance for a input vector from a GaussianModel
12  //
13  int main() {
14
15    // declare the GaussianModel object
16    //
17    GaussianModel gauss;
18
19    // declare mean and covariance matrix to define gaussian
20    //
21    VectorFloat mean(L"1.0, 1.0, 1.0");
22    MatrixFloat cov(3, 3, L"0.1, 0.1, 0.1", Integral::DIAGONAL);
23
24    // set gaussian
25    //
26    gauss.setMean(mean);
27    gauss.setCovariance(cov);
28
29    // declare the input vector
30    //
31    VectorFloat input;
32    input.assign(L"-1, -1, -1");
33
34    // get the distance
35    //
36    Float distance = gauss.getLogLikelihood(input);
37
38    // output the result to the console output
39    //
40    distance.debug(L"Mahalanobis Distance:");
41
42    // exit gracefully
43    //
44    Integral::exit();
45  }
```
Explanation:
In the above example, the declaration on line 17 creates a GaussianModel object. On line 21 we create a VectorFloat object, which is initialized as the mean vector for GaussianModel. On line 22 we create a MatrixFloat object, which is initialized as the covariance matrix for GaussianModel. Next, on line 26 and line 27 we set the GaussianModel object with the mean vector and covariance matrix. After setting the input vector on line 32, we can simply use the getLogLikelihood method of the GaussianModel object to get the Mahalanobis distance for the input vector from the GaussianModel.

Line 40 demonstrates how to send output to the terminal using debug method. The output for this code is the following:

`  <Float::Mahalanobis Distance:> value_d = -59.3029`
Example:
The next example uses MixtureModel to show how a mixture distribution is created:
```01  // file: \$isip/doc/examples/class/stat/stat_example_01/example.cc
02  // version: \$Id: index.html 10251 2005-09-16 19:14:10Z srinivas \$
03  //
04
05  // isip include files
06  //
07  #include <GaussianModel.h>
08  #include <UniformModel.h>
09  #include <MixtureModel.h>
10
11  // main program starts here:
12  //  this example demonstrates how to use MixtureModel to combining several
13  //  statistical models for creation of mixture distributions
14  //
15  int main() {
16
17    // declare the MixtureModel object
18    //
19    MixtureModel model;
20
21    // declare GaussianModel and UniformModel objects
22    //
23    GaussianModel gauss;
24    UniformModel uniform;
25
26    // set the GaussianModel object
27    //
28    VectorFloat mean(L"1, 2, 3");
29    MatrixFloat covar(3, 3, L"4, 5, 6", Integral::DIAGONAL);
30    gauss.setMean(mean);
31    gauss.setCovariance(covar);
32
33    // set the UniformModel object
34    //
35    VectorFloat min(L"-1, -2, -3");
36    VectorFloat max(L"1, 2, 3");
37    uniform.setMin(min);
38    uniform.setMax(max);
39
40    // add model objects into the MixtureModel object
41    //
44
45    // set the weights for two model objects
46    //
47    VectorFloat weights(L"0.3, 0.7");
48    model.setWeights(weights);
49
50    // declare the input vector
51    //
52    VectorFloat input;
53    input.assign(L"-0.9, -1.2, -2.3");
54
55    // score the input vector
56    //
57    Float score = model.getLikelihood(input);
58    Float gauss_score = gauss.getLikelihood(input);
59    Float uniform_score = uniform.getLikelihood(input);
60
61    // output the result to the console output
62    //
63    gauss_score.debug(L"First model's score:");
64    uniform_score.debug(L"Second model's score:");
65    weights.debug(L"Weights for models:");
66    score.debug(L"Final score:");
67
68    // exit gracefully
69    //
70    Integral::exit();
71  }```
Explanation:
In the above example, the declaration on line 19 creates a MixtureModel object. On line 23 and line 24 we create a GaussianModel object and a UniformModel object. On line 28 and line 29 we create and initialize a mean vector and a covariance matrix for GaussianModel. Then on line 30 and line 31 we set the GaussianModel object with the mean vector and covariance matrix. From line 35 to line 38 we set the minimum vector and maximum vector for UniformModel. Then on line 42 and line 43 the GaussianModel object and UniformModel object are added into the MixtureModel object. On line 47 and line 48 the weights of the MixtureModel object are set. After setting the input vector on line 53, we can simply use the getLikelihood method of the MixtureModel object to get the linear combination score for the input vector from the mixture distribution.

Line 63, 64, 65 and 66 demonstrates how to send output to the terminal using debug method. The output for this code is the following:

```  <Float::First model's score:> value_d = 0.000127596
<Float::Second model's score:> value_d = 0.0208333
<VectorFloat::Weights for models:> length_d = 2
<VectorFloat::Weights for models:> capacity_d = 2
<VectorFloat::Weights for models:> v_d = 0.3, 0.7
<Float::Final score:> value_d = 0.0146216```
A detailed listing of the basic interfaces for the statistical model classes can be found in the StatisticalModelBase header file documentation (for functions shared across all classes) or the individual class documentation (for example, see the GaussianModel class). The statistical model classes that are available include:

 GaussianModel Histogram MixtureModel NGramModel RelevanceVectorModel StatisticalModel SupportVectorModel UniformModel

The next level in the ISIP class hierarchy is algorithm which provides algorithms used in the front-end of a speech recognition system. The software corresponding to the examples demonstrated in this document can be found in our documentation directory under class/stat/.