The work described here reports on the improvement of a Raman lidar algorithm for measuring aerosol extinction. In order to calculate aerosol extinction from Raman lidar data it is necessary to perform the derivative of a molecular Raman signal with respect to altitude. The typical approach taken in the lidar community is to make an a priori assumption about the functional behavior of the data in order to calculate the derivative. Here a technique is shown that uses the chi-squared test to determine the most likely functional behavior of the data prior to actually calculating the derivative. A mathematical simulation is described that shows the capabilities of this technique and the possibility of reducing the extinction uncertainties with respect to traditional techniques.