title: How to convert distance into probability?
body: <p>Сan anyone shine a light to my matlab program?
  I have data from two sensors and i'm doing a <code>kNN</code> classification for each of them separately.
  In both cases training set looks like a set of vectors of 42 rows total, like this:</p>
  
  <pre><code>[44 12 53 29 35 30 49;
  
   54 36 58 30 38 24 37;..]
  </code></pre>
  
  <p>Then I get a sample, e.g. <code>[40 30 50 25 40 25 30]</code> and I want to classify the sample to its closest neighbor.
  As a criteria of proximity I use Euclidean metrics, <strong>sqrt(sum(Y<sup>2</sup>))</strong>, where <code>Y</code> is a difference between each element and it gives me an array of distances between Sample and each Class of Training Set.</p>
  
  <p>So, two questions:</p>
  
  <ul>
  <li>Is it possible to convert distance into distribution of probabilities, something like: Class1: 60%, Class 2: 30%, Class 3: 5%, Class 5: 1%, etc.</li>
  </ul>
  
  <p>added: Up to this moment I'm using formula: <code>probability = distance/sum of distances</code>, but I cannot plot a correct <code>cdf</code> or histogram.
  This gives me a distribution in some way, but I see a problem there, because if distance is large, for example 700, then the closest class will get a biggest probability, but it'd be wrong because the distance is too big to be compared with any of classes.</p>
  
  <ul>
  <li>If I would be able to get two probability density functions, I guess then I would do some product of them. Is it possible?</li>
  </ul>
  
  <p>Any help or remark is highly appreciated.</p>