title: How does condensed distance matrix work? (pdist)
body: <p><code>scipy.spatial.distance.pdist</code> returns a condensed distance matrix. From <a href="http://docs.scipy.org/doc/scipy/reference/generated/scipy.spatial.distance.pdist.html" rel="noreferrer">the documentation</a>:</p>
  
  <blockquote>
    <p>Returns a condensed distance matrix Y. For each  and  (where ), the metric dist(u=X[i], v=X[j]) is computed and stored in entry ij.</p>
  </blockquote>
  
  <p>I thought <code>ij</code> meant <code>i*j</code>. But I think I might be wrong. Consider</p>
  
  <pre class="lang-py prettyprint-override"><code>X = array([[1,2], [1,2], [3,4]])
  dist_matrix = pdist(X)
  </code></pre>
  
  <p>then the documentation says that <code>dist(X[0], X[2])</code> should be <code>dist_matrix[0*2]</code>. However, <code>dist_matrix[0*2]</code> is 0 -- not 2.8 as it should be. </p>
  
  <p>What's the formula I should use to access the similarity of a two vectors, given <code>i</code> and <code>j</code>?</p>