There are two form of the linearization formula.  Use whichever makes sense to you. The derivations are to allow you to take two measurements with the sensor, one close and one far away, and to plug them into the formula to get the constants needed to convert the inverse binary output of the sensor to a linear, calibrated output.  On Dilbert I used 1/10" increments and a byte results which gave me a linear range of 0~25" (0 to 255).  So, I measured at 5 inches (D = 50) and 20 inches (D = 200), recorded the raw output of the sensors, turned the crank on the calculator and came up with Kg and Ko.

The symbols are:

bulletD = Distance in whatever units you desire, I used 1/10 inch increments.
bulletKg = Gain Constant, determines the shape of the inverse curve
bulletKo = Offset Constant, shifts the inverse curve up and down
bulletX = output of Sharp sensor in Decimal.
bulletD' & X' are the second set of measurements

The first form, the one I used in Dilbert

  1.  D = Kg/(X - Ko)
  2. Get Kg on one side of the equation.
  3. D (X - Ko) = Kg
  4. Take two measurements, call them D and D' and the results X and X'  With #3 and the appropriate Ko, the two measurements will be equal, so:
  5. D (X -Ko) = Kg =  D' (X' - Ko)
  6. Ignore Kg and solve for Ko
  7. DX - DKo = D'X' - D'Ko
  8. Ko(D'-D) = D'X' - DX
  9. Ko = (D'X' - DX)/(D' - D)
  10. Repeat 3-9 but solve for Kg (make Ko be on one side of the equation)
  11. X-Ko = Kg/D
  12. X - Kg/D = Ko
  13. X-Kg/D = Ko =  X' - Kg/D' (this is a repeat of #4, above)
  14. Kg/D'-Kg/D = X'-X
  15. Kg (D-D')/D'D = X'-X
  16. Kg = (X'-X) D'D/(D-D')
Here is an alternate form of the calibration equation that should have an expanded range of inputs and outputs compared to the first one. 
  1. D = Kg/X - Ko
  2. We'll just cut to the chase here
  3. Ko = (D'X' - DX)/(X-X')
  4. Kg = XX' (D-D')/(X'-X)