Results 1 to 8 of 8

Math Help - Curve fitting

  1. #1
    Newbie
    Joined
    Nov 2008
    From
    United Kingdom
    Posts
    13

    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
    Follow Math Help Forum on Facebook and Google+

  2. #2
    Grand Panjandrum
    Joined
    Nov 2005
    From
    someplace
    Posts
    14,972
    Thanks
    4
    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
    Follow Math Help Forum on Facebook and Google+

  3. #3
    Newbie
    Joined
    Nov 2008
    From
    United Kingdom
    Posts
    13
    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
    Follow Math Help Forum on Facebook and Google+

  4. #4
    Grand Panjandrum
    Joined
    Nov 2005
    From
    someplace
    Posts
    14,972
    Thanks
    4
    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
    Follow Math Help Forum on Facebook and Google+

  5. #5
    Newbie
    Joined
    Nov 2008
    From
    United Kingdom
    Posts
    13
    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.
    Follow Math Help Forum on Facebook and Google+

  6. #6
    Banned
    Joined
    Nov 2008
    Posts
    82
    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; November 23rd 2008 at 01:22 AM.
    Follow Math Help Forum on Facebook and Google+

  7. #7
    Grand Panjandrum
    Joined
    Nov 2005
    From
    someplace
    Posts
    14,972
    Thanks
    4
    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
    Follow Math Help Forum on Facebook and Google+

  8. #8
    Newbie
    Joined
    Nov 2008
    From
    United Kingdom
    Posts
    13
    Hi,

    Thank you CaptainBlack and David24 for valuable help.

    Best wishes,
    Follow Math Help Forum on Facebook and Google+

Similar Math Help Forum Discussions

  1. [SOLVED] Exponential Curve Fitting
    Posted in the Advanced Math Topics Forum
    Replies: 11
    Last Post: April 1st 2011, 03:36 AM
  2. Curve Fitting
    Posted in the Advanced Algebra Forum
    Replies: 11
    Last Post: November 23rd 2010, 04:55 PM
  3. Curve Fitting
    Posted in the Calculus Forum
    Replies: 8
    Last Post: September 15th 2010, 03:09 PM
  4. Curve Fitting 2
    Posted in the Calculus Forum
    Replies: 8
    Last Post: September 15th 2010, 07:38 AM
  5. Fitting a curve to a form
    Posted in the Advanced Statistics Forum
    Replies: 1
    Last Post: May 12th 2009, 06:43 PM

Search Tags


/mathhelpforum @mathhelpforum