title: Algorithm for creating a score based on percent and distance
body: <p>I'm trying to calculate a score based on two pieces of data: percentage and distance. Both of these are used in ranking colors.</p>
  
  <p><code>Percentage</code> can range from 0 to 100, and can be a decimal. In fact, most of the time it is a decimal and not a whole number. Percentage is important because it means there is more of a color occurring in an image. </p>
  
  <p><code>Distance</code> can also be from 0 to 100 and is also can be a decimal. The distance is calculated in a more complex way... essentially each color has a true value and a mapped value. The mapped value is a pre-set color, so in simple terms <code>true_color - map_color = distance</code>. The distance is how different the true color is from the mapped color. </p>
  
  <p>My problem seems to be in how to weight the numbers so that a high percentage with a smaller distance should rank higher than a high percentage with a bigger distance. Here are some attempts that I've made:</p>
  
  <p>This is how I believe the data should be ordered because it puts weight on percentage with distance (accuracy) in mind rather than just percentage.</p>
  
  <pre><code>7 percent, 0.5 distance  = 140 (1st)
  4 percent, 0.02 distance = 200 (2nd)
  2 percent, 1 distance    = 200 (3rd)
  10 percent, 8 distance   = 125 (4th)
  10 percent, 50 distance  = 125 (5th)
  </code></pre>
  
  <p>However, I keep coming up with this order based on my formula:</p>
  
  <pre><code>t = 100 // max distance possible
  
  4 percent * (t / 0.02 distance) = 20,000
  7 percent * (t / 0.5 distance)  = 1400
  2 percent * (t / 1 distance)    = 200
  10 percent * (t / 8 distance)   = 125
  10 percent * (t / 50 distance)  = 20
  </code></pre>
  
  <p><strong>Any ideas on how to fix this?</strong></p>