<p>In <a href="https://github.com/mlpack/mlpack/pull/749#discussion_r76761769">src/mlpack/methods/lsh/lshmodel_impl.hpp</a>:</p>
<pre style='color:#555'>&gt; +  Timer::Start(&quot;pairwise_distances&quot;);
&gt; +  arma::vec distances(numSamples * (numSamples - 1) / 2);
&gt; +  size_t d = 0; // Index of where to store next.
&gt; +  for (size_t i = 0; i &lt; numSamples; ++i)
&gt; +    for (size_t j = i + 1; j &lt; numSamples; ++j)
&gt; +      distances(d++) = metric::EuclideanDistance::Evaluate(
&gt; +          sampleSet.unsafe_col(i), sampleSet.unsafe_col(j));
&gt; +  Log::Info &lt;&lt; &quot;Computed &quot; &lt;&lt; d &lt;&lt; &quot; pointwise distances.&quot; &lt;&lt; std::endl;
&gt; +  Timer::Stop(&quot;pairwise_distances&quot;);
&gt; +
&gt; +  // Step 3. Estimate statistics of these distances: log(mean(d)), mean(log(d)),
&gt; +  // mean(d).
&gt; +  distances = arma::pow(distances, 2);
&gt; +  this-&gt;meanDist = arma::mean(distances);
&gt; +  this-&gt;logMeanDist = std::log(meanDist);
&gt; +  this-&gt;meanLogDist = arma::mean(arma::log(distances));
</pre>
<p>This works. I'll have to test how it affects correctness once the other details are ironed out.</p>

<p>I wonder if my way of calculating the geometric mean creates the problem:</p>

<p>I use the exp(log( prod(...) ))  to compute the geometric mean. That is correct assuming the products (i.e. distances) are strictly positive numbers, since the logarithm is undefined for &lt;= 0. The geometric mean, though, is defined for 0s as well, but it is simply equal to 0. <br>
The authors haven't specified this, and I would expect the gamma distribution with geometric mean equal to 0 to be undefined, but do you think simply setting geometric means to 0 in this case be sufficient?</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/749/files/a0626a8c41fedc60ec255ef2939a519dfac5b83a#r76761769">view it on GitHub</a>, or <a href="https://github.com/notifications/unsubscribe-auth/AJ4bFGNmzw6N5kbbAx1Mp6BCBlr4GTYtks5qk_k2gaJpZM4JczVR">mute the thread</a>.<img alt="" height="1" src="https://github.com/notifications/beacon/AJ4bFLbu5NWQVKwWtEaOpuvS_xIgmInWks5qk_k2gaJpZM4JczVR.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/749/files/a0626a8c41fedc60ec255ef2939a519dfac5b83a#r76761769"></link>
  <meta itemprop="name" content="View Pull Request"></meta>
</div>
<meta itemprop="description" content="View this Pull Request on GitHub"></meta>
</div>

<script type="application/json" data-scope="inboxmarkup">{"api_version":"1.0","publisher":{"api_key":"05dde50f1d1a384dd78767c55493e4bb","name":"GitHub"},"entity":{"external_key":"github/mlpack/mlpack","title":"mlpack/mlpack","subtitle":"GitHub repository","main_image_url":"https://cloud.githubusercontent.com/assets/143418/17495839/a5054eac-5d88-11e6-95fc-7290892c7bb5.png","avatar_image_url":"https://cloud.githubusercontent.com/assets/143418/15842166/7c72db34-2c0b-11e6-9aed-b52498112777.png","action":{"name":"Open in GitHub","url":"https://github.com/mlpack/mlpack"}},"updates":{"snippets":[{"icon":"PERSON","message":"@mentekid in #749: This works. I'll have to test how it affects correctness once the other details are ironed out.\r\n\r\nI wonder if my way of calculating the geometric mean creates the problem:\r\n\r\nI use the exp(log( prod(...) ))  to compute the geometric mean. That is correct assuming the products (i.e. distances) are strictly positive numbers, since the logarithm is undefined for \u003c= 0. The geometric mean, though, is defined for 0s as well, but it is simply equal to 0. \r\nThe authors haven't specified this, and I would expect the gamma distribution with geometric mean equal to 0 to be undefined, but do you think simply setting geometric means to 0 in this case be sufficient?"}],"action":{"name":"View Pull Request","url":"https://github.com/mlpack/mlpack/pull/749/files/a0626a8c41fedc60ec255ef2939a519dfac5b83a#r76761769"}}}</script>