This file is indexed.

/usr/share/doc/libitpp-dev/html/mog.html is in libitpp-doc 4.2-4.

This file is owned by root:root, with mode 0o644.

The actual contents of the file can be viewed below.

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<head>
  <meta http-equiv="Content-Type" content="text/html;charset=utf-8">
  <title>Welcome to IT++!</title>
  <link href="doxygen.css" rel="stylesheet" type="text/css">
  <link href="tabs.css" rel="stylesheet" type="text/css">
  <link rel="shortcut icon" href="favicon.ico">
</head>
<body>
<div style="width: 100%; height: 40px; background-color: #ffff00; border: 1px solid #b0b0b0; margin: 5px 5px 5px 0; padding: 2px;">
  <a href="http://itpp.sourceforge.net"><img src="itpp_logo.png" alt="IT++ Logo" style="float: left; border: 0;"></a>
</div>
<!-- Generated by Doxygen 1.7.4 -->
<script type="text/javascript"><!--
var searchBox = new SearchBox("searchBox", "search",false,'Search');
--></script>
  <div id="navrow1" class="tabs">
    <ul class="tablist">
      <li><a href="index.html"><span>Main&#160;Page</span></a></li>
      <li class="current"><a href="pages.html"><span>Related&#160;Pages</span></a></li>
      <li><a href="modules.html"><span>Modules</span></a></li>
      <li><a href="namespaces.html"><span>Namespaces</span></a></li>
      <li><a href="annotated.html"><span>Classes</span></a></li>
      <li><a href="files.html"><span>Files</span></a></li>
      <li><a href="dirs.html"><span>Directories</span></a></li>
      <li id="searchli">
        <div id="MSearchBox" class="MSearchBoxInactive">
        <span class="left">
          <img id="MSearchSelect" src="search/mag_sel.png"
               onmouseover="return searchBox.OnSearchSelectShow()"
               onmouseout="return searchBox.OnSearchSelectHide()"
               alt=""/>
          <input type="text" id="MSearchField" value="Search" accesskey="S"
               onfocus="searchBox.OnSearchFieldFocus(true)" 
               onblur="searchBox.OnSearchFieldFocus(false)" 
               onkeyup="searchBox.OnSearchFieldChange(event)"/>
          </span><span class="right">
            <a id="MSearchClose" href="javascript:searchBox.CloseResultsWindow()"><img id="MSearchCloseImg" border="0" src="search/close.png" alt=""/></a>
          </span>
        </div>
      </li>
    </ul>
  </div>
</div>
<div class="header">
  <div class="headertitle">
<div class="title">Using Mixture of Gaussians (MOG) module to model data </div>  </div>
</div>
<div class="contents">
<div class="textblock"><p>This example demonstrates how to find the parameters of a MOG model via using the kmeans and EM based optimisers. Synthetic data is utilised.</p>
<div class="fragment"><pre class="fragment"><span class="preprocessor">#include &lt;<a class="code" href="itstat_8h.html" title="Include file for the IT++ statistics module.">itpp/itstat.h</a>&gt;</span>

<span class="preprocessor">#include &lt;fstream&gt;</span>
<span class="preprocessor">#include &lt;iostream&gt;</span>
<span class="preprocessor">#include &lt;iomanip&gt;</span>
<span class="preprocessor">#include &lt;ios&gt;</span>

<span class="keyword">using</span> std::cout;
<span class="keyword">using</span> std::endl;
<span class="keyword">using</span> std::fixed;
<span class="keyword">using</span> std::setprecision;

<span class="keyword">using namespace </span>itpp;

<span class="keywordtype">int</span> main()
{

  <span class="keywordtype">bool</span> print_progress = <span class="keyword">false</span>;

  <span class="comment">//</span>
  <span class="comment">// first, let&#39;s generate some synthetic data</span>

  <span class="keywordtype">int</span> N = 100000;  <span class="comment">// number of vectors</span>
  <span class="keywordtype">int</span> D = 3;       <span class="comment">// number of dimensions</span>
  <span class="keywordtype">int</span> K = 5;       <span class="comment">// number of Gaussians</span>

  <a class="code" href="classitpp_1_1Array.html">Array&lt;vec&gt;</a> X(N);
  <span class="keywordflow">for</span> (<span class="keywordtype">int</span> n = 0;n &lt; N;n++) { X(n).set_size(D); X(n) = 0.0; }

  <span class="comment">// the means</span>

  <a class="code" href="classitpp_1_1Array.html">Array&lt;vec&gt;</a> mu(K);
  mu(0) = <span class="stringliteral">&quot;-6, -4, -2&quot;</span>;
  mu(1) = <span class="stringliteral">&quot;-4, -2,  0&quot;</span>;
  mu(2) = <span class="stringliteral">&quot;-2,  0,  2&quot;</span>;
  mu(3) = <span class="stringliteral">&quot; 0, +2, +4&quot;</span>;
  mu(4) = <span class="stringliteral">&quot;+2, +4, +6&quot;</span>;


  <span class="comment">// the diagonal variances</span>

  <a class="code" href="classitpp_1_1Array.html">Array&lt;vec&gt;</a> var(K);
  var(0) = <span class="stringliteral">&quot;0.1, 0.2, 0.3&quot;</span>;
  var(1) = <span class="stringliteral">&quot;0.2, 0.3, 0.1&quot;</span>;
  var(2) = <span class="stringliteral">&quot;0.3, 0.1, 0.2&quot;</span>;
  var(3) = <span class="stringliteral">&quot;0.1, 0.2, 0.3&quot;</span>;
  var(4) = <span class="stringliteral">&quot;0.2, 0.3, 0.1&quot;</span>;

  cout &lt;&lt; fixed &lt;&lt; setprecision(3);
  cout &lt;&lt; <span class="stringliteral">&quot;user configured means and variances:&quot;</span> &lt;&lt; endl;
  cout &lt;&lt; <span class="stringliteral">&quot;mu = &quot;</span> &lt;&lt; mu &lt;&lt; endl;
  cout &lt;&lt; <span class="stringliteral">&quot;var = &quot;</span> &lt;&lt; var &lt;&lt; endl;

  <span class="comment">// randomise the order of Gaussians &quot;generating&quot; the vectors</span>
  <a class="code" href="classitpp_1_1I__Uniform__RNG.html" title="Integer uniform distributionExample: Generation of random uniformly distributed integers in the inter...">I_Uniform_RNG</a> rnd_uniform(0, K - 1);
  ivec gaus_id = rnd_uniform(N);

  ivec gaus_count(K);
  gaus_count = 0;
  <a class="code" href="classitpp_1_1Array.html">Array&lt;vec&gt;</a> mu_test(K);
  <span class="keywordflow">for</span> (<span class="keywordtype">int</span> k = 0;k &lt; K;k++) { mu_test(k).set_size(D); mu_test(k) = 0.0; }
  <a class="code" href="classitpp_1_1Array.html">Array&lt;vec&gt;</a> var_test(K);
  <span class="keywordflow">for</span> (<span class="keywordtype">int</span> k = 0;k &lt; K;k++) { var_test(k).set_size(D); var_test(k) = 0.0; }

  <a class="code" href="classitpp_1_1Normal__RNG.html" title="Normal distributionNormal (Gaussian) random variables, using a simplified Ziggurat method...">Normal_RNG</a> rnd_normal;
  <span class="keywordflow">for</span> (<span class="keywordtype">int</span> n = 0;n &lt; N;n++) {

    <span class="keywordtype">int</span> k = gaus_id(n);
    gaus_count(k)++;

    <span class="keywordflow">for</span> (<span class="keywordtype">int</span> d = 0;d &lt; D;d++) {
      rnd_normal.<a class="code" href="classitpp_1_1Normal__RNG.html#a9c50b4c9b0bb07c69c9fbf16b9f01521" title="Set mean, and variance.">setup</a>(mu(k)(d), var(k)(d));
      <span class="keywordtype">double</span> tmp = rnd_normal();
      X(n)(d) = tmp;
      mu_test(k)(d) += tmp;
    }
  }

  <span class="comment">//</span>
  <span class="comment">// find the stats for the generated data</span>

  <span class="keywordflow">for</span> (<span class="keywordtype">int</span> k = 0;k &lt; K;k++) mu_test(k) /= gaus_count(k);

  <span class="keywordflow">for</span> (<span class="keywordtype">int</span> n = 0;n &lt; N;n++) {
    <span class="keywordtype">int</span> k = gaus_id(n);

    <span class="keywordflow">for</span> (<span class="keywordtype">int</span> d = 0;d &lt; D;d++) {
      <span class="keywordtype">double</span> tmp = X(n)(d) - mu_test(k)(d);
      var_test(k)(d) += tmp * tmp;
    }
  }

  <span class="keywordflow">for</span> (<span class="keywordtype">int</span> k = 0;k &lt; K;k++)  var_test(k) /= (gaus_count(k) - 1.0);

  cout &lt;&lt; endl &lt;&lt; endl;
  cout &lt;&lt; fixed &lt;&lt; setprecision(3);
  cout &lt;&lt; <span class="stringliteral">&quot;stats for X:&quot;</span> &lt;&lt; endl;

  <span class="keywordflow">for</span> (<span class="keywordtype">int</span> k = 0;k &lt; K;k++) {
    cout &lt;&lt; <span class="stringliteral">&quot;k = &quot;</span> &lt;&lt; k &lt;&lt; <span class="stringliteral">&quot;  count = &quot;</span> &lt;&lt; gaus_count(k) &lt;&lt; <span class="stringliteral">&quot;  weight = &quot;</span> &lt;&lt; gaus_count(k) / double(N) &lt;&lt; endl;
    <span class="keywordflow">for</span> (<span class="keywordtype">int</span> d = 0;d &lt; D;d++) cout &lt;&lt; <span class="stringliteral">&quot;  d = &quot;</span> &lt;&lt; d &lt;&lt; <span class="stringliteral">&quot;  mu_test = &quot;</span> &lt;&lt; mu_test(k)(d) &lt;&lt; <span class="stringliteral">&quot;  var_test = &quot;</span> &lt;&lt; var_test(k)(d) &lt;&lt; endl;
    cout &lt;&lt; endl;
  }


  <span class="comment">// make a model with initial values (zero mean and unit variance)</span>
  <span class="comment">// the number of gaussians and dimensions of the model is specified here</span>

  <a class="code" href="classitpp_1_1MOG__diag.html" title="Diagonal Mixture of Gaussians (MOG) class.">MOG_diag</a> mog(K, D);

  cout &lt;&lt; endl;
  cout &lt;&lt; fixed &lt;&lt; setprecision(3);
  cout &lt;&lt; <span class="stringliteral">&quot;mog.avg_log_lhood(X) = &quot;</span> &lt;&lt; mog.avg_log_lhood(X) &lt;&lt; endl;

  <span class="comment">//</span>
  <span class="comment">// find initial parameters via k-means (which are then used as seeds for EM based optimisation)</span>

  cout &lt;&lt; endl &lt;&lt; endl;
  cout &lt;&lt; <span class="stringliteral">&quot;running kmeans optimiser&quot;</span> &lt;&lt; endl &lt;&lt; endl;

  <a class="code" href="group__MOG.html#gadeb91bf337a38234135d6d402e3143b3">MOG_diag_kmeans</a>(mog, X, 10, 0.5, <span class="keyword">true</span>, print_progress);

  cout &lt;&lt; fixed &lt;&lt; setprecision(3);
  cout &lt;&lt; <span class="stringliteral">&quot;mog.get_means() = &quot;</span> &lt;&lt; endl &lt;&lt; mog.get_means() &lt;&lt; endl;
  cout &lt;&lt; <span class="stringliteral">&quot;mog.get_diag_covs() = &quot;</span> &lt;&lt; endl &lt;&lt; mog.get_diag_covs() &lt;&lt; endl;
  cout &lt;&lt; <span class="stringliteral">&quot;mog.get_weights() = &quot;</span> &lt;&lt; endl &lt;&lt; mog.get_weights() &lt;&lt; endl;

  cout &lt;&lt; endl;
  cout &lt;&lt; <span class="stringliteral">&quot;mog.avg_log_lhood(X) = &quot;</span> &lt;&lt; mog.avg_log_lhood(X) &lt;&lt; endl;


  <span class="comment">//</span>
  <span class="comment">// EM ML based optimisation</span>

  cout &lt;&lt; endl &lt;&lt; endl;
  cout &lt;&lt; <span class="stringliteral">&quot;running ML optimiser&quot;</span> &lt;&lt; endl &lt;&lt; endl;

  <a class="code" href="group__MOG.html#ga7b86d84e61a3056418f08b7ac0686805">MOG_diag_ML</a>(mog, X, 10, 0.0, 0.0, print_progress);

  cout &lt;&lt; fixed &lt;&lt; setprecision(3);
  cout &lt;&lt; <span class="stringliteral">&quot;mog.get_means() = &quot;</span> &lt;&lt; endl &lt;&lt; mog.get_means() &lt;&lt; endl;
  cout &lt;&lt; <span class="stringliteral">&quot;mog.get_diag_covs() = &quot;</span> &lt;&lt; endl &lt;&lt; mog.get_diag_covs() &lt;&lt; endl;
  cout &lt;&lt; <span class="stringliteral">&quot;mog.get_weights() = &quot;</span> &lt;&lt; endl &lt;&lt; mog.get_weights() &lt;&lt; endl;

  cout &lt;&lt; endl;
  cout &lt;&lt; <span class="stringliteral">&quot;mog.avg_log_lhood(X) = &quot;</span> &lt;&lt; mog.avg_log_lhood(X) &lt;&lt; endl;

  <span class="keywordflow">return</span> 0;
}
</pre></div> </div></div>
<!-- window showing the filter options -->
<div id="MSearchSelectWindow"
     onmouseover="return searchBox.OnSearchSelectShow()"
     onmouseout="return searchBox.OnSearchSelectHide()"
     onkeydown="return searchBox.OnSearchSelectKey(event)">
<a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(0)"><span class="SelectionMark">&#160;</span>All</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(1)"><span class="SelectionMark">&#160;</span>Classes</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(2)"><span class="SelectionMark">&#160;</span>Namespaces</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(3)"><span class="SelectionMark">&#160;</span>Files</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(4)"><span class="SelectionMark">&#160;</span>Functions</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(5)"><span class="SelectionMark">&#160;</span>Variables</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(6)"><span class="SelectionMark">&#160;</span>Typedefs</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(7)"><span class="SelectionMark">&#160;</span>Enumerations</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(8)"><span class="SelectionMark">&#160;</span>Enumerator</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(9)"><span class="SelectionMark">&#160;</span>Friends</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(10)"><span class="SelectionMark">&#160;</span>Defines</a></div>

<!-- iframe showing the search results (closed by default) -->
<div id="MSearchResultsWindow">
<iframe src="javascript:void(0)" frameborder="0" 
        name="MSearchResults" id="MSearchResults">
</iframe>
</div>

<div style="clear: both; width: 100%; height: 31px; background-color: #ffff00; border: 1px solid #b0b0b0; margin: 5px 5px 5px 0; padding: 2px;">
  <a href="http://sourceforge.net"><img src="http://sourceforge.net/sflogo.php?group_id=37044&amp;type=1" alt="SourceForge Logo" style="float: right; border: 0;"></a>
  <p style="padding-left: 10px; font-size: 85%;">Generated on Wed Jul 27 2011 16:27:06 for IT++ by <a href="http://www.doxygen.org/index.html">Doxygen</a> 1.7.4</p>
</div>
</body>
</html>