Discover MakerZone

MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi

Learn more

Discover what MATLAB® can do for your career.

Opportunities for recent engineering grads.

Apply Today

Thread Subject:
Curve fitting - retrieve original values after centering and scaling

Subject: Curve fitting - retrieve original values after centering and scaling

From: Michael Ranftelhuber

Date: 15 Jul, 2013 15:44:06

Message: 1 of 5

Hi,

I have a problem with the curve fitting toolbox. I want to fit a curve through measured dispersion points of a fiber to get the higher orders of dispersion. The dispersion is generalliy defined as:

D(w) = beta1 + beta2(x) + beta3./2.*(x^2) + ...

where beta1, beta2, beta3, ... are the values I want. Looks like a simple polynomial to me. However when I put the data into cftool and make a fit it warns me: "Equation is badly conditioned. Remove repeated data points or try centering and scaling".

But scaling obviously changes the fitting parameters, which is what I want. How can I rescale the system in order to get the "real" beta1, ... values from the scaled polynomial coefficients p1, p2, ...?

This is really a huge problem for me atm!

Thanks!

Subject: Curve fitting - retrieve original values after centering and scaling

From: Chris

Date: 21 Jul, 2013 19:57:10

Message: 2 of 5


The trick is to put the polynomial coefficients from the fit back into the expression with the renormalized x_norm values, substitute x_norm = mu*(x+xmean), and solve for the coefficients you want in terms of those from the fit.

You may want to check my math but for a cubic equation the coefficients you want are (in terms of those from the fit):

b1 = b1fit + b2fit*mu*xm + b3fit*mu^2*xm^2/2
b2 = b2fit*mu + b3fit*mu^2*xm
b3 = b3fit*mu^2/2

Here mu=std deviation and xm=mean of your data.

Subject: Curve fitting - retrieve original values after centering and scaling

From: Chris

Date: 21 Jul, 2013 19:58:10

Message: 3 of 5

... quadratic equation, like the one you showed...

Subject: Curve fitting - retrieve original values after centering and scaling

From: Michael Ranftelhuber

Date: 29 Jul, 2013 19:09:11

Message: 4 of 5

Dear Chris,

thank you very much for your answer. I now implemented an "unscaling" algorithm, which basically retrieves the unscaled fitting parameters from the scaled ones that Matlab's cftool returns.

I have a little question: May it be that I loose the advantages of scaling and centering (especially the smaller variability against small changes of the fitting routine) when doing that?

I have a problem that massively changes all fitting parameters simply when in/decreasing the order of a polynomial fit when not centered and scaled, while it is much more stable when centering and scaling. When I then, however retrieve the unscaled fitting coefficients from the scaled fit, I again get the high variability.

Is there anything I can do? I need the parameters for the unscaled fit, as this is the important result.

Thanks a lot again,

Michael


"Chris " <cfweise@yahoo.com> wrote in message <kshegi$au$1@newscl01ah.mathworks.com>...
> ... quadratic equation, like the one you showed..M

Subject: Curve fitting - retrieve original values after centering and scaling

From: Chris

Date: 30 Jul, 2013 16:19:11

Message: 5 of 5

If you are interested in interpreting your fitting coefficients then of course it is important to unnormalize them. However, to retain numerical stability during evaluation of the polynomial y = sum(i){p_i*x^i} for particular x it is a good idea to use the normalized x and p_i.

I hope this answers your question and leads to a solution!

Tags for this Thread

No tags are associated with this thread.

What are tags?

A tag is like a keyword or category label associated with each thread. Tags make it easier for you to find threads of interest.

Anyone can tag a thread. Tags are public and visible to everyone.

Contact us