Math Help Forum

Math Help Forum Feed Site Feed

Go Back   Math Help Forum > Math Resources > Computer Software
Reply
 
Thread Tools Display Modes
  #1  
Old 11-16-2008, 11:00 AM
Junior Member
 
Join Date: Nov 2008
Posts: 7
Country:
Thanks: 0
Thanked 0 Times in 0 Posts
rainy cloud is on a distinguished road
Default Curve fitting

Hi everyone,

I have a question regarding curve fitting to data.
My question is:
If I have some data points one of them is (0,0) and when I fit them to a curve, how can I control this fitting curve and force it to pass a definite point like (0,0).

Could anyone give help in this question?


Thank you in advance.

RainyCloud
Reply With Quote
Advertisement
 
  #2  
Old 11-16-2008, 12:00 PM
Grand Panjandrum


 
Join Date: Nov 2005
Posts: 10,426
Thanks: 517
Thanked 2,784 Times in 2,291 Posts
CaptainBlack has disabled reputation
Default

Quote:
Originally Posted by rainy cloud View Post
Hi everyone,

I have a question regarding curve fitting to data.
My question is:
If I have some data points one of them is (0,0) and when I fit them to a curve, how can I control this fitting curve and force it to pass a definite point like (0,0).

Could anyone give help in this question?


Thank you in advance.

RainyCloud
1. Adjust the weights in the objective so that the (0,0) point is weighted more heavily than the others.

2. Choose a family of fitting functions all of which pass through (0,0).

CB
Reply With Quote
  #3  
Old 11-16-2008, 03:44 PM
Junior Member
 
Join Date: Nov 2008
Posts: 7
Country:
Thanks: 0
Thanked 0 Times in 0 Posts
rainy cloud is on a distinguished road
Default

Hi CaptainBlack,

Thank you very much for your answer. Unfortunately, I haven't understood what you mean by adjusting the weights in the objective. Also, in 2., how can I choose a family of fitting functions pass through the (0,0) point.

Another point, how can I judge that a curve is the best fitting?

Thank you again.

RainyCloud
Reply With Quote
  #4  
Old 11-17-2008, 10:06 PM
Grand Panjandrum


 
Join Date: Nov 2005
Posts: 10,426
Thanks: 517
Thanked 2,784 Times in 2,291 Posts
CaptainBlack has disabled reputation
Default

Quote:
Originally Posted by rainy cloud View Post
Hi CaptainBlack,

Thank you very much for your answer. Unfortunately, I haven't understood what you mean by adjusting the weights in the objective. Also, in 2., how can I choose a family of fitting functions pass through the (0,0) point.

Another point, how can I judge that a curve is the best fitting?

Thank you again.

RainyCloud
You had better tell us what you know about curve fitting, and/or more background to your problem.

CB
Reply With Quote
  #5  
Old 11-18-2008, 05:55 PM
Junior Member
 
Join Date: Nov 2008
Posts: 7
Country:
Thanks: 0
Thanked 0 Times in 0 Posts
rainy cloud is on a distinguished road
Default

Quote:
Originally Posted by CaptainBlack View Post
You had better tell us what you know about curve fitting, and/or more background to your problem.

CB
What I understand about curve fitting, if I have some data points, we need to look for a function which fits these points provided the distance between the points and the curve of the function satisfy as small as they can.

I am really not sure about that I hope you correct my thought.

The following some data, how can I choose the best curve fitting for them
E=[1 0.9 0.8 0.7 0.6 0.5 0.4 0.3 0.2 0.1 0]
C=[0.016123 0.015483 0.014737 0.013991 0.013190 0.012331 0.011478 0.010518 0.009398 0.008172 0.006781]

figure(1)
plot(E,C,
'bx')

Thank you again.
Reply With Quote
  #6  
Old 11-23-2008, 02:02 AM
Member
 
Join Date: Nov 2008
Posts: 79
Country:
Thanks: 0
Thanked 22 Times in 22 Posts
David24 is on a distinguished road
Default

Quote:
Originally Posted by rainy cloud View Post
Hi everyone,

I have a question regarding curve fitting to data.
My question is:
If I have some data points one of them is (0,0) and when I fit them to a curve, how can I control this fitting curve and force it to pass a definite point like (0,0).

Could anyone give help in this question?


Thank you in advance.

RainyCloud

Hey mate,

here you wish to fit a curve f(x) over a set of data points say X such that the residual is minimised and the function passes through the origin,

i.e f(0) = 0

why not let f(x) = xg(x) and model to solve g(x),

i.e. lets say you wish to fit a polynomial to X that must pass through the origin
then f(x) = x( a0 + a1*x + .... + an*x^n) which for any solution of a0, a1, ... an will definately pass through the origin.

If we want to extend this so that at x = a, f(a) = A, then all that is required is a simple modification to the function as before

let f(x) = (x-a)g(x) + A
and solve for g(x), we observe that at x = a f(a) = A

hope this helps,

David

Last edited by David24; 11-23-2008 at 02:22 AM.
Reply With Quote
  #7  
Old 11-23-2008, 02:33 AM
Grand Panjandrum


 
Join Date: Nov 2005
Posts: 10,426
Thanks: 517
Thanked 2,784 Times in 2,291 Posts
CaptainBlack has disabled reputation
Default

Quote:
Originally Posted by rainy cloud View Post
What I understand about curve fitting, if I have some data points, we need to look for a function which fits these points provided the distance between the points and the curve of the function satisfy as small as they can.

I am really not sure about that I hope you correct my thought.

The following some data, how can I choose the best curve fitting for them
E=[1 0.9 0.8 0.7 0.6 0.5 0.4 0.3 0.2 0.1 0]
C=[0.016123 0.015483 0.014737 0.013991 0.013190 0.012331 0.011478 0.010518 0.009398 0.008172 0.006781]

figure(1)
plot(E,C,
'bx')

Thank you again.

You will not be able to get a decent fit to this data with a curve that goes through (0,0).

You will get a reasonably good fit from a quadratic, but the residuals show that this is not a statistically good fit. To do the job properly we need theory to tell us what the expected form of the curve is.

Below is some Euler code that does a quadratic fit, this should be easy to translate into Matlab and to modify the objective to any form you like.

Code:
>
>function Obj(v,E,C)
$  cpred=v(1)*E^2+v(2)*E+v(3);
$  err=(C-cpred)^2;
$  Err=sum(err);
$  return Err
$endfunction
>
>
>help nelder
nelder is a builtin function.

brent("f",a,d,eps) returns a minimum close to a. The function
goes away from a with step size d until it finds a good interval
to start a fast iteration. Additional parameters are passed to f.
nelder("f",v,d,eps) for multidimenional functions f(v), accepting
1xn vectors. d is the initial simplex size.
eps is the final accuracy.

Used by: neldermin, brentmin

>v=[0,0,0.012]
            0             0         0.012 
>Obj(v,E,C)
 9.32421e-005 
>xx=nelder("Obj",v,1,1e-12;E,C)
  -0.00361415     0.0127619    0.00690228 
>yy=xx(1)*E^2+xx(2)*E+xx(3);
>
>xplot(E,yy);
>hold on;color(5);plot(E,C);hold off;
>
CB
Reply With Quote
  #8  
Old 11-27-2008, 06:21 AM
Junior Member
 
Join Date: Nov 2008
Posts: 7
Country:
Thanks: 0
Thanked 0 Times in 0 Posts
rainy cloud is on a distinguished road
Default

Hi,

Thank you CaptainBlack and David24 for valuable help.

Best wishes,
Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off
Forum Jump


All times are GMT -7. The time now is 07:54 PM.


Powered by vBulletin® Version 3.7.3
Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
SEO by vBSEO 3.2.0 ©2008, Crawlability, Inc.
©2005 - 2008 Math Help Forum


Math Help Forum is a community of maths forums with an emphasis on maths help in all levels of mathematics.
Register to post your math questions or just hang out and try some of our math games or visit the arcade.