title: Array data normalization
body: <p>I have an array of values (between -1.0 and 1.0) that represent intensity (Black to White).  I need a way to map the double values from -1.0 through 1.0 to 0 through 255 and back.</p>
  
  <p>More generalized, I have an array of data and I need to map from the min and max value of the data to a supplied min and max.  Basic structure should be like:</p>
  
  <pre><code>private static int[] NormalizeData(double[] data, int min, int max)
  {
      var sorted = data.OrderBy(d =&gt; d);
      double dataMax = sorted.First();
      double dataMin = sorted.Last();
      int[] ret = new int[data.Length];
  
      for (int i = 0; i &lt; data.Length; i++)
      {
          ret[i] = (int)data[i];  // Normalization here
      }
  
      return ret;
  }
  </code></pre>