"Shape preserving" fitting algorithms Does anyone know if there is such a thing as a "shape preserving" fitting algorithm? Now and then I run into the following problem: I have a set of rapidly varying data and try to fit it using an equation with e.g. 5 unknowns; I know that I can make it fit "by hand" (basically trial and error). However, when I try to fit it I often get that the solution is e.g. a straight line through the data; simply because it is a "good" solution in the least-square sense(although it doesn't make much sense from physical point of view). The wiki on the MLA even shows one example of this. I can obviously get it to fit if I start with a "good" guess but that sort of defies the purpose of automatic fitting (and I often need to fit hundreds of experimental curves and sometimes in "real time" so doing it by hand is not really an option). I understand that the problem is -there are several minima and the fitting algorithms finds the "wrong one" unless the initial conditions are close to the real solution- but I don't know how to solve it. Presumably this is well-known problem, but I haven't been able to find a reference where they discuss possible solutions. Is there any way of adding "shape preservation" to e.g. the MLA? E.g. by somehow adding that the condition for a "best fit" is that also the derivatives fit reasonably well? Or are there any other possible solutions?