Armin Mueller <arm.in@web.de> wrote in message <icbulh$440$1@news2.rz.unikarlsruhe.de>...
> Dear NG,
>
> I would like to calculate the inverse function of a (measured) curve
> which should be strictly decreasing. However, the data is noisy and not
> 100% perfect.
>
> To fix the curve, I've written some lines of code that drop all points
> that are increasing or level. However, I have the dim feeling that the
> code could be shorter and more elegant. Any idea how?
> .......
          
Why not do a sort with the decreasing option on 'curve'? If its deviation from nonincreasing monotonicity is due only to small noise effects, the swapping of 'curve' values due to the sorting would all occur in local regions and the overall curve's characteristics would be essentially preserved. This way you would not have to drop any points at all.
Such a procedure may seem heretical because it violates the sanctity of the curve's ordinate and abscissa value pairings, but that really is no more fundamental a change than the disturbance produced by noise, assuming that the theoretical noisefree curve is indeed monotone.
This does not necessarily produce a strictly decreasing result. For that you would have to play further tricks on the curve values. I can think of a few but I'll let you ponder the matter.
Another notion would be to apply some sort of smoothing filter to the curve values which would hopefully render it monotone if done properly. The choice of appropriate filter would of course depend on the nature of the noise.
Roger Stafford
