<?php $isip_window_title = "ISIP Homepage"; ?>
<?php include("/data/isip/www/templates/documentation/header/header.html"); ?>
<?php include("/data/isip/www/templates/documentation/body/bar.html"); ?>

<!--#set var="isip_page_title" value="STATISTICS" -->
<!--#include virtual="/hse/ies/templates/documentation/body/title.html" -->

<b>Library Name:</b>
lib_stat.a

<br><br>

<b>Introduction:</b>

<br><br>

<ul>
  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.
</ul>

<b>Example:</b>

<ul>
  Let's begin with a simple

  <a href="../../doc/examples/class/stat/stat_example_00/">example</a>:

  <pre>
01  // file: $isip/doc/examples/class/stat/stat_example_00/example.cc
02  // version: $Id: index.html 10653 2007-02-24 20:33:16Z tm334 $
03  //
04
05  // isip include files
06  //
07  #include &lt;GaussianModel.h&gt
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  }
</pre>
</ul>

<b>Explanation:</b>

<ul>
  In the above example, the declaration on line 17 creates
  a <a href="./GaussianModel/index.html">GaussianModel</a> 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.

  <br><br>
  
  Line 40 demonstrates how to send output to the terminal using debug
  method. The output for this code is the following:
  
  <br><br>
  
  <pre>
  &lt;Float::Mahalanobis Distance:&gt; value_d = -59.3029</pre>
</ul>

<b>Example:</b>

<ul>
  The next <a
  href="../../doc/examples/class/stat/stat_example_01/">example</a> uses
  MixtureModel to show how a mixture distribution is created:

  <pre>
01  // file: $isip/doc/examples/class/stat/stat_example_01/example.cc
02  // version: $Id: index.html 10653 2007-02-24 20:33:16Z tm334 $
03  //
04
05  // isip include files
06  //
07  #include &lt;GaussianModel.h&gt
08  #include &lt;UniformModel.h&gt
09  #include &lt;MixtureModel.h&gt
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    //
42    model.add(gauss);
43    model.add(uniform);
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  }</pre>
</ul>

<b>Explanation:</b>

<ul>
  In the above example, the declaration on line 19 creates
  a <a href="./MixtureModel/index.html">MixtureModel</a> object. On line 23 and
  line 24 we create a <a
  href="./GaussianModel/index.html">GaussianModel</a> object and a <a
  href="./UniformModel/index.html">UniformModel</a> 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.

  <br><br>
  
  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:
  
  <br><br>
  
  <pre>
  &lt;Float::First model's score:&gt; value_d = 0.000127596
  &lt;Float::Second model's score:&gt; value_d = 0.0208333
  &lt;VectorFloat::Weights for models:&gt; length_d = 2
  &lt;VectorFloat::Weights for models:&gt; capacity_d = 2
  &lt;VectorFloat::Weights for models:&gt; v_d = 0.3, 0.7
  &lt;Float::Final score:&gt; value_d = 0.0146216</pre>
</ul>

<ul>
  A detailed listing of the basic interfaces for the statistical
  model classes can be found in the

  <a href="/perl/ifc_document.pl?file=$isip/class/stat/StatisticalModel/StatisticalModelBase.h">StatisticalModelBase</a>

  header file documentation (for functions shared across all classes) or
  the individual class documentation (for example, see the

  <a href="/perl/ifc_document.pl?file=$isip/class/stat/GaussianModel/GaussianModel.h">GaussianModel</a>

  class). The statistical model classes that are available include:

  <br><br>

  <center>
  <table border=5>
  
  <tr>
  <td> <a href="./GaussianModel/index.html">GaussianModel</a> </td>
  <td> <a href="./Histogram/index.html">Histogram</a> </td>
  <td> <a href="./MixtureModel/index.html">MixtureModel</a> </td>
  <td> <a href="./NGramModel/index.html">NGramModel</a> </td>
  </tr>

  <tr>
  <td> <a href="./RelevanceVectorModel/index.html">RelevanceVectorModel</a> </td>
  <td> <a href="./StatisticalModel/index.html">StatisticalModel</a> </td>
  <td> <a href="./SupportVectorModel/index.html">SupportVectorModel</a> </td>
  <td> <a href="./UniformModel/index.html">UniformModel</a> </td>
  </tr>
  
  </table>
  </center>
  
  <br>
  
  The next level in the ISIP class hierarchy is
  
  <a href="../algo/index.html">algorithm</a>
  
  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

  <a href="../../doc/examples/">documentation directory</a>

  under

  <a href="../../doc/examples/class/stat/">class/stat/</a>.
</ul>

<!--#include virtual="/hse/ies/templates/documentation/footer/footer.html" -->
