bit OT: Multivariable nonlinear regression

I need to convert some compressor curves into a 3-d equation for modelling purposes, P = f(Q,V), where P is pressure, Q flow and V a vane position. For fixed V, the P-Q relationship is well behaved, and monotonic (avoiding the surge region) within the domain of interest, essentially a segment of a parabola or cubic. As V varies, the curves shift, rescale and rotate slightly.

I can generate a table of spot values of the variables, but the regression functions I've come across such as the Excel linest function, seems to be confined to linear functions. Can anyone suggest a tool that will faciliate deriving a polynomial (or other form) equation to model my datasets? The alternative is the very fiddly process of manually working out variable coefficients for the constant-V curves that model them as they shift around.

Being a real engineering problem, I'm hoping for a quick and easy solution, precision isn't essential. otoo +/- 10% would do. TIA

Reply to
Bruce Varley
Loading thread data ...

If you have Scilab or similar, you can get the coefficients of a polynomial pretty quickly.

I.e., if you're looking for a best fit to y(x) = a*x^2 + b*x + c, then make your measurements of y vs. x, put x into a column vector, then do

X = [ones(x) x x.^2]; b = X \ y;

Scilab automatically sees that the problem is overconstrained and finds a least-squares solution for b, which has the coefficients of your polynomial in it.

This code should work the same in Scilab, Octave, and Matlab.

I hope this answers your question...

Reply to
Tim Wescott

Just in case anyone might find this useful...

Solved it sort of, with a semi-manual procedure that could be fully automated with a bit more work, but discovered a gotcha in the process:

ATTEMPT #1 The curves supplied are pressure vs flow, with 8 separate lines, one for each suction vane position. For each I did a quadratic regression using Excel, providing a K2i, K1i and K0i. Then I did a regression on each of the Ks, also quadratic, to get an equation for how each of the three varied with the vane position. So you can calculate the Ks for a particular vane position, and they will apply for the P-Q curve at that position.

The results of this were rubbish, no way near good enough to use. The problem is the minor fit inaccuracies in the K regressions, P-Q 2nd order calc amplifies them hugely.

ATTEMPT #2 Repeated this with a linear regression for each P-Q curve, giving only a K1i and K0i. Some fidelity loss, but the variation in process gain as the vanes move is preserved, that's probably the most important thing. The resulting calc hits the linear estimations spot on.

That explains (I guess) why all the freeware 3-d regressions that google throws up are based on linear equations.

Reply to
Bruce Varley

Thanks for posting your result.

I've found that this sort of thing can get pretty hairy when you go beyond a linear fit. Basically, if I'm going to fit to more than linear I try to understand the underlying physics, and see if I can use that to inspire what I should be fitting to.

Note that you don't have to fit to a polynomial: you can fit to sines and cosines (basically do a truncated Fourier series), or you can fit to 1, sqrt(x), x, ..., or you can take the log and fit that, etc.

Reply to
Tim Wescott

PolyTech Forum website is not affiliated with any of the manufacturers or service providers discussed here. All logos and trade names are the property of their respective owners.