<p>In <a href="https://github.com/mlpack/mlpack/pull/694#discussion_r69922415">src/mlpack/core/data/imputation_methods/median_imputation.hpp</a>:</p>
<pre style='color:#555'>&gt; +              const bool transpose = true)
&gt; +  {
&gt; +    //initiate output
&gt; +    output = input;
&gt; +
&gt; +    if (transpose)
&gt; +    {
&gt; +      arma::Mat&lt;T&gt; medianMat = arma::median(input, 1);
&gt; +      for (size_t i = 0; i &lt; input.n_cols; ++i)
&gt; +      {
&gt; +        if (input(dimension, i) == mappedValue ||
&gt; +            std::isnan(input(dimension, i)))
&gt; +        {
&gt; +          output(dimension, i) = medianMat(dimension, 0);
&gt; +        }
&gt; +      }
</pre>
<p>Iterate non contiguous memory frequently would slow down the speed. But in this case I think this is necessary, because this imputation is apply to a single row only</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/a8818316a04506530e2269a2e0a32ba2f6a1c83b#r69922415">view it on GitHub</a>, or <a href="https://github.com/notifications/unsubscribe/AJ4bFI01tnSTuI0TSFZ4NZqy3Mj06ysSks5qTRQJgaJpZM4I07W-">mute the thread</a>.<img alt="" height="1" src="https://github.com/notifications/beacon/AJ4bFG07_yj_NVQG8GOLmx0uF7SOM3beks5qTRQJgaJpZM4I07W-.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/a8818316a04506530e2269a2e0a32ba2f6a1c83b#r69922415"></link>
  <meta itemprop="name" content="View Pull Request"></meta>
</div>
<meta itemprop="description" content="View this Pull Request on GitHub"></meta>
</div>