Fitting a curve in log-linear plot.

  • Context: Undergrad 
  • Thread starter Thread starter mikewinifred
  • Start date Start date
  • Tags Tags
    Curve Fitting Plot
Click For Summary

Discussion Overview

The discussion revolves around the challenge of fitting a curve through six data points in a log-linear plot. Participants explore the concepts of interpolation versus curve fitting, the implications of using a logarithmic scale for the x-axis, and the nature of the relationship between the variables involved.

Discussion Character

  • Exploratory
  • Technical explanation
  • Debate/contested

Main Points Raised

  • One participant inquires about the type of curve expected, noting that the scattered nature of the data might suggest a straight line rather than a complex curve.
  • Another participant clarifies that fitting a curve through specific points is termed "interpolating," and suggests using a parametric representation for the curve.
  • A proposed method for interpolation involves defining functions for x and y in terms of a parameter t, leading to simultaneous equations to solve for unknown coefficients.
  • There is a distinction made between interpolation and curve fitting, with one participant emphasizing that curve fitting aims for a function that approximates the points in a least squares sense.
  • The original poster confirms that y is a function of x, but notes the x-axis is on a logarithmic scale, raising questions about how this affects the interpolated formula.
  • Another participant challenges the notion that y is a function of x based on the drawn curve, pointing out potential multiple y values for some x values.
  • A further inquiry is made regarding the nature of the data and the rationale for using a log-linear plot, suggesting that the curve may not need to pass through all data points due to measurement uncertainty.
  • One participant provides an example of how a specific functional form can be represented in a log-linear plot, indicating that the resulting line from least-squares regression may not intersect the data points.

Areas of Agreement / Disagreement

Participants express differing views on whether y is a function of x based on the drawn curve. There is also a lack of consensus on whether the curve should pass through all data points, with some suggesting it is unusual for it to do so.

Contextual Notes

Participants note the importance of understanding the nature of the data and the potential uncertainty in measurements, which may affect the appropriateness of interpolation versus fitting.

mikewinifred
Messages
8
Reaction score
0
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

  • logLinearFit.png
    logLinearFit.png
    5.1 KB · Views: 563
Physics news on Phys.org
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.
 
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.
 
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.
 
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.
 
mikewinifred said:
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.
 
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:

Similar threads

  • · Replies 16 ·
Replies
16
Views
3K
  • · Replies 3 ·
Replies
3
Views
2K
  • · Replies 11 ·
Replies
11
Views
3K
  • · Replies 4 ·
Replies
4
Views
2K
  • · Replies 22 ·
Replies
22
Views
4K
  • · Replies 28 ·
Replies
28
Views
3K
  • · Replies 5 ·
Replies
5
Views
2K
Replies
28
Views
4K
  • · Replies 22 ·
Replies
22
Views
4K
  • · Replies 1 ·
Replies
1
Views
2K