<p>I think I solved the problem.</p>

<p>This problem happens due to miscalculations.<br>
The cosines and cosineMax are computed two times (in CosineTree::CosineNodeSplit and in the test).<br>
And the first cosineMax may differ significantly from the second one.</p>

<p>For example, look at the debug output below<br>
<code>THIS IS TREE 0xbcbe978</code><br>
<code>cosineMax = 0.99999999999999988898</code><br>
<code>cosineMin = 0.73421824357373099978</code><br>
<code>cosines</code><br>
<code>0.75763372746624790821 0.75999261009165319791 0.75479082605226166525</code> <code>0.75788044353107164586 0.99999999999999988898 0.73421824357373099978</code><br>
<code>THIS IS TEST 0xbcbe978</code><br>
<code>TreeDepth = 11</code><br>
<code>cosineMax = 0.75999261009165330893</code><br>
<code>cosineMin = 0.73421824357373111081</code><br>
<code>cosines</code><br>
<code>1 0.75763372746624801923 0.75999261009165330893 0.75479082605226177627</code> <code>0.7578804435310718679 0.73421824357373111081</code></p>

<p>All sets differ by a calculational accuracy of double (about 1e-16 around 1.0).<br>
And the first cosineMax differs significantly from the second one because the second one equals 1 exactly (<code>cosineMax = arma::max(cosines % (cosines &lt; 1));</code>).</p>

<p>I suggest to compare doubles with some precision. I correct the test. This should fix the problem.</p>

<hr>

<h4>You can view, comment on, or merge this pull request online at:</h4>
<p>&nbsp;&nbsp;<a href='https://github.com/mlpack/mlpack/pull/581'>https://github.com/mlpack/mlpack/pull/581</a></p>

<h4>Commit Summary</h4>
<ul>
  <li>Fix bug #358 (CosineTreeTest/CosineNodeCosineSplit test sometimes fails, only on i386)</li>
</ul>

<h4>File Changes</h4>
<ul>
  <li>
    <strong>M</strong>
    <a href="https://github.com/mlpack/mlpack/pull/581/files#diff-0">src/mlpack/tests/cosine_tree_test.cpp</a>
    (60)
  </li>
</ul>

<h4>Patch Links:</h4>
<ul>
  <li><a href='https://github.com/mlpack/mlpack/pull/581.patch'>https://github.com/mlpack/mlpack/pull/581.patch</a></li>
  <li><a href='https://github.com/mlpack/mlpack/pull/581.diff'>https://github.com/mlpack/mlpack/pull/581.diff</a></li>
</ul>

<p style="font-size:small;-webkit-text-size-adjust:none;color:#666;">&mdash;<br />You are receiving this because you are subscribed to this thread.<br />Reply to this email directly or <a href="https://github.com/mlpack/mlpack/pull/581">view it on GitHub</a><img alt="" height="1" src="https://github.com/notifications/beacon/AJ4bFNr-yht-5csSAkYTSJlWRdWUWL8Fks5pudiDgaJpZM4HzbKc.gif" width="1" /></p>
<div itemscope itemtype="http://schema.org/EmailMessage">
<div itemprop="action" itemscope itemtype="http://schema.org/ViewAction">
  <link itemprop="url" href="https://github.com/mlpack/mlpack/pull/581"></link>
  <meta itemprop="name" content="View Pull Request"></meta>
</div>
<meta itemprop="description" content="View this Pull Request on GitHub"></meta>
</div>