2

I have a problem where I am fitting a high-order polynomial to (not very) noisy data using linear least squares. Currently I'm using polynomial orders around 15 - 25, which work surprisingly well: The dependence is very nearly linear, but the accuracy of modelling the 'very nearly' is critical. I'm using Matlab's polyfit() function, and (obviously) normalising the x-data. This generally works fine, but I have come across an issue with some recent datasets. The fitted polynomial has extrema within the x-data interval. For the application I'm working on this is a non-no. The polynomial model must have no stationary points over the x-interval.

So I need to add a constraint to the least-squares problem: the derivative of the fitted polynomial must be strictly positive over a known x-range (or strictly negative - this depends on the data but a simple linear fit will quickly tell me which it is.) I have had a quick look at the available optimisation toolbox functions, but I admit I'm at a loss to know how to go about this. Does anyone have any suggestions?

[I appreciate there are probably better models than polynomials for this data, but in the short term it isn't feasible to change the form of the model]

[A closing note: I have finally got the go-ahead to replace this awful polynomial model! I am going to adopt a nonparametric approach, spline smoothing, using the excellent SPLINEFIT code by Jonas Lundgren. This has the advantage that I'm already using a spline model in the end-user application, so I already have C# code available to evaluate a spline model]

Max
  • 2,121
  • 3
  • 16
  • 20
  • High-order polynomials are not always the answer, and they do have their share of [problems](http://blogs.mathworks.com/loren/2008/07/17/interpolating-polynomials/#9). To quote the author of that post (@woodchips), sometimes it helps to "break the problem up and use smaller segments of low order polynomials, pieced together"... – Amro Oct 29 '11 at 01:04
  • Yes indeed. Although I'm approximating, not interpolating, a polynomial is not generally the best way to go. Unfortunately, my problem 'grew' from trying to model a relatively small, smoothly-curving part of the underlying physical process to a more extended region. My Matlab code builds a model which is used by production code in C#, and that is more difficult to get changed. I've written a proposal to re-implement the model using a Radial Basis Function network, but until (if) that gets adopted, I need a way to tame my polynomials! – Max Oct 29 '11 at 08:41
  • High order polynomials are not a good solution, for SO MANY reasons. Staying with them out of inertia may well cause you many problems in the future. The reason I did not answer your question was because you refused to change. My response would be to use a modeling tool that will allow you to specify things like monotonicity, positivity, fix points easily, etc. My slmengine does exactly that. But if you won't change, there is no reason to waste my time or yours. –  Oct 30 '11 at 10:40
  • Inertia is not the reason! I have to request budget to change not only my Matlab code but also the deployed application software that depends on the form of the model. The answer is, as always, no, because 'it works'. Except that increasingly it doesn't. Anyway, that was yesterday's problem. The joys of being just one of 110,000 employees... – Max Nov 10 '11 at 14:05
  • Can you give an example? At least show a plot? – Andrey Rubshtein Nov 14 '11 at 08:45

1 Answers1

0

You could use cftool and use the exclude data points option.

Naresh
  • 105
  • 5
  • Naresh - I am using the optimisation toolbox, not curve-fitting toolbox. The fitting process is automatic (there are about 500 data points per fit) and already uses robust techniques to down-weight outliers in the data – Max Nov 10 '11 at 14:08