Fitting a curve in log-linear plot.

  • #1

Main Question or Discussion Point

Hi all,

I want to fit a curve through 6 points (please see figure attached, the curve in the picture is a drawn one not a fitted one. That is just to give a feel how the fitted curve would look like.) in a log-linear plot. Is there any way I can do it? Thanks.
 

Attachments

Answers and Replies

  • #2
Simon Bridge
Science Advisor
Homework Helper
17,847
1,644
What sort of curve are you expecting?

The data in your example are so scattered it could almost probably a straight line! You would not normally assume the points represent the wigglyness of the curve in the way you just did.
 
  • #3
Stephen Tashi
Science Advisor
7,017
1,237
When you want a curve to go exactly through a number of points, this is called "interpolating" a curve rather than "fitting" a curve. An interesting thing about your problem is that, in the curve you drew, y is not a function of x. This suggests trying a parametric representation where x = f(t) and y = g(t).

I can't tell whether your goal is to find a "nice" formula for the curve that only involves a few multiplications and divisions or whether you would be satisfied with a curve that had several different sections, each with a different formula for it. An example of defining an interpolation curve in pieces is "spline" interpolation.


For a "one piece fit", you could try setting
[itex] f(t) = a_0 + a_1 t + a_2 t^2 + ...+a_5 t^5 [/itex]
[itex] g(t) = b_0 + b_1 t + b_2 t^2 + ...+b_5 t^5 [/itex]

where [itex] a_i, b_i [/itex] are unknown constants. Substituting the data points [itex] (x_k,y_k, t_k) [/itex] in those equations gives you a series of simultaneous equations to solve for [itex] a_i,b_i [/itex]. (You can make up the values of the [itex] t_k [/itex] anyway that satisifes [itex] t_1 < t_2 < ...t_6 [/itex].)

This is one way out of an infinite number of ways to find a curve through the points and the look of the curve you get this way not please you. To change the look of the curve you have to add more unknown coefficients. To get a unique answer for those coefficients you have to add more conditions. For example, you could pick points on the curve you drew by hand and add them to the data. Or you could specify desired values of the slope of the curve at various points.
 
  • #4
87
0
Looking at the picture, I have to agree with Stephen. That problem is called interpolation. Curve fitting means you try to find a function that is close to those points in the least squares sense.
 
  • #5
Thanks Stephen and others for the reply. Y is indeed a function of X. The only thing is X is in Log scale and Y is in linear scale. Yup am shooting for a nice formula, which will go through all the points. Since the horizontal axis is in Log scale , how it is going to affect the interpolated formula? Thanks.
 
  • #6
Stephen Tashi
Science Advisor
7,017
1,237
Y is indeed a function of X.
Y is not a function of X as you drew the curve. There are some X values for which there are two possible Y values. That can't occur if you want Y to be a function of X.
 
  • #7
Simon Bridge
Science Advisor
Homework Helper
17,847
1,644
This is where, to properly advise you, we need to know what the data represents: what did you measure that you plotted to get that graph? Why were you plotting a lin-log plot - what was this supposed to achieve?

I suspect that your curve is not supposed to go through all the data points. That's quite unusual.

For instance - if your data is expected to come from a function of form:
[itex]y=y_0e^{\lambda x}[/itex]

and you measure y for set values of x

then if you plot the natural logarithm of y against x you get a line:
[itex]\ln|y| = \ln|y_0| + \lambda x[/itex]

... with slope and intercept that can be found by least-squares regression (or max/min estimates). The line you get this way is unlikely to pass through any of the data points - expected since the data points are known to be uncertain: they are measurements after all.

Examples:
http://facstaff.unca.edu/mcmcclur/class/LinearII/presentations/html/leastsquares.html
... covers polynomial interpolation through to curve fitting using matlab or gnu octave.
 
Last edited by a moderator:

Related Threads on Fitting a curve in log-linear plot.

Replies
1
Views
4K
  • Last Post
Replies
1
Views
2K
  • Last Post
Replies
16
Views
1K
  • Last Post
Replies
2
Views
3K
  • Last Post
Replies
4
Views
2K
  • Last Post
Replies
9
Views
3K
  • Last Post
Replies
4
Views
19K
  • Last Post
Replies
1
Views
1K
  • Last Post
Replies
4
Views
391
  • Last Post
Replies
11
Views
2K
Top