<p>In <a href="https://github.com/mlpack/mlpack/pull/694#discussion_r68376091">src/mlpack/tests/imputation_test.cpp</a>:</p>
<pre style='color:#555'>&gt; +BOOST_AUTO_TEST_CASE(MeanImputationTest)
&gt; +{
&gt; +  arma::mat input(&quot;3.0 0.0 2.0 0.0;&quot;
&gt; +                  &quot;5.0 6.0 0.0 6.0;&quot;
&gt; +                  &quot;9.0 8.0 4.0 8.0;&quot;);
&gt; +  arma::mat outputT; // assume input is transposed
&gt; +  arma::mat output;  // assume input is not transposed
&gt; +  double mappedValue = 0.0;
&gt; +
&gt; +  MeanImputation&lt;double&gt; imputer;
&gt; +
&gt; +  // transposed
&gt; +  imputer.Apply(input, outputT, mappedValue, 0/*dimension*/, true);
&gt; +
&gt; +  BOOST_REQUIRE_CLOSE(outputT(0, 0), 3.0, 1e-5);
&gt; +  BOOST_REQUIRE_CLOSE(outputT(0, 1), 2.5, 1e-5);
</pre>
<p>No matter how I calculate, the mean value should be 5.66666667<br>
3+5+9+6+8+2+4+6+8 = 51<br>
51/9 =  5.66666667</p>

<p>Maybe it is because to you forgot to initialize sum?</p>

<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, <a href="https://github.com/mlpack/mlpack/pull/694/files/da4e40981c40e171858f41de4e85e08af2c7e48d..d8618ec909005b0453f0a3803ac1e6cc5e588f1f#r68376091">view it on GitHub</a>, or <a href="https://github.com/notifications/unsubscribe/AJ4bFAajelzehlFncEgT1pAiMMV0GATLks5qO6aAgaJpZM4I07W-">mute the thread</a>.<img alt="" height="1" src="https://github.com/notifications/beacon/AJ4bFJcvrHoYt0yCBIxixxTDPV2ULcDJks5qO6aAgaJpZM4I07W-.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/694/files/da4e40981c40e171858f41de4e85e08af2c7e48d..d8618ec909005b0453f0a3803ac1e6cc5e588f1f#r68376091"></link>
  <meta itemprop="name" content="View Pull Request"></meta>
</div>
<meta itemprop="description" content="View this Pull Request on GitHub"></meta>
</div>