<p>Hi there!</p>

<p>There seems to be no check on the cluster size when it's decreased, yet it's used afterwards for update the variance. So, if the cluster size reaches zero, the variance is infinity. As a result, the cluster gets chosen next iteration and causes access to <code>furthestPoint == data.n_cols</code>, which is rather sad.<br>
I simply added the same condition as in <code>Precalculate</code>.</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/481'>https://github.com/mlpack/mlpack/pull/481</a></p>

<h4>Commit Summary</h4>
<ul>
  <li>kmeans: small fix with inf variance</li>
</ul>

<h4>File Changes</h4>
<ul>
  <li>
    <strong>M</strong>
    <a href="https://github.com/mlpack/mlpack/pull/481/files#diff-0">src/mlpack/methods/kmeans/max_variance_new_cluster_impl.hpp</a>
    (5)
  </li>
</ul>

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

<p style="font-size:small;-webkit-text-size-adjust:none;color:#666;">&mdash;<br>Reply to this email directly or <a href="https://github.com/mlpack/mlpack/pull/481">view it on GitHub</a>.<img alt="" height="1" src="https://github.com/notifications/beacon/AJ4bFL77LrBoPD7YU4JA0Kw0XrJaqaioks5pId4UgaJpZM4GnIi6.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/481"></link>
  <meta itemprop="name" content="View Pull Request"></meta>
</div>
<meta itemprop="description" content="View this Pull Request on GitHub"></meta>
</div>