I can't fit these numbers

I have these few numbers

x-axis y-axis
0.001 1
0.01 17
0.1 9
1 1

and want to have a smooth curve in a log-log plot. So I plotted the points and in order to smooth them tried to make a fit. Most fits won't work and a poly fit results in a fit that does not by far resemble the data.
I am very new to Igor, and most probably miss something.
I'd appreciate any suggestion.

thanks, Dominik
Hi,

I have similar issues, and I have a (painful) solution, so I'm hoping that someone else chimes in with an easier answer.

I do a similar sequence of steps when I have to curve fit something that is a ERFC(x) function on a LOG-LOG plot, but is a straight line on a doubleLOG-LOG plot. I keep copies of all of the waves along the way, plot them, and compare the quality of the curve-fits on each (using the cursors to fit some or all of the curves, and end up curve fitting and converting in both directions).


If you're looking for a smooth curve (polynomial) fit on a log-log plot, then here is a working sequence.

1) duplicate your xaxis wave as LOG_xaxis and your yaxis wave as LOG_yaxis

2) execute the following LOG_xaxis = log(xaxis) and the same for the Y

3) then, fit the new curves using the polynomial fit, AND use destination "_auto_"

4) This will generate the coefficients (in W_coef) and fit wave called "fit_LOG_yaxis"
You'll have to do your own math transforms for the coefficients to turn them into something useful for you in the LOG-LOG domain.

The fit wave doesn't have a separate X-axis wave associated with it because it has evenly spaced points generated in a WAVE SCALING
So, you can make one like this:

DUPLICATE fit_log_yaxis fitX_log_yaxis
fitX_log_yaxis = x (This will copy the X-scaling into the wave)

Now you can get the same plot by DISPLAYing fit_LOG_yaxis vs _calculated_ OR fit_LOG_yaxis vs fitX_LOG_yaxis



5) To append the fit to your log-log plot, do the following

fit_log_yaxis = 10^(fit_log_yaxis)
fitX_log_yaxis = 10^(fitX_log_yaxis)

Then append these to your original Log-Log plot

AppendToGraph fit_log_yaxis vs fitx_log_yaxis

(This will mess up your parabolic fit curves, so you could duplicate your fit_ and fitX_ waves first - it's up to you)

This works, but it is PAINFUL.
It is easy to do in a script, but generates lots of dummy waves along the way, and you have to be VERY careful with the lengths of the wave names.
31 characters is the limit.


Does someone have another way to do this?????????


Thank you!!

Sean







Wow, Sean - that sounds complicated! I will have to play around with this for a little. If this is so complicated, I am tempted to 'fit' it with a Bezier curve.

Thanks!

Dominik
Do you just want a 'pretty line', or do you want to know what that pretty line is?

This technique will get you both.
(It's overkill if you just want the smooth line instead of the point-to-point straight-line-connected data.)
(are you looking for the options that you see in the XY scatter plot Wizard in XL?)

Sean
dhezel wrote:
I have these few numbers
x-axis y-axis
0.001 1
0.01 17
0.1 9
1 1
and want to have a smooth curve in a log-log plot.


FWIW, assuming that all you want is a trend curve, the function below pasted into the macro window works ....

Function InverseParabolicLog(w,x) : FitFunc
    Wave w
    Variable x

    //CurveFitDialog/ These comments were created by the Curve Fitting dialog. Altering them will
    //CurveFitDialog/ make the function less convenient to work with in the Curve Fitting dialog.
    //CurveFitDialog/ Equation:
    //CurveFitDialog/ f(x) = 10^(a*log(x)^2 + b*log(x) + c)
    //CurveFitDialog/ End of Equation
    //CurveFitDialog/ Independent Variables 1
    //CurveFitDialog/ x
    //CurveFitDialog/ Coefficients 3
    //CurveFitDialog/ w[0] = a
    //CurveFitDialog/ w[1] = b
    //CurveFitDialog/ w[2] = c

    return 10^(w[0]*log(x)^2 + w[1]*log(x) + w[2])
End


The attached image shows the results for the following parameters (where a = w[0], b = w[1], and c = w[2]):

  Coefficient values ± one standard deviation
    a   =-0.72579 ± 0.163
    b   =-2.4507 ± 0.498
    c   =-0.76834 ± 0.347


Perhaps you have a theoretical curve that you are wanting instead to fit to the data, or you are just wanting to play the equivalent of what I call "connect the dots" using a "smooth" line. In the former case, you would code your theoretical function and fit it. In the latter, you might consider using the drawing tools and just draw an arc. Some explanation along this line of where you are really heading would help.

--
J. J. Weimer
Chemistry / Chemical & Materials Engineering, UAHuntsville
FitGraph.jpg (49.8 KB)
Using the built-in logNormal fit function results in a picture just like the one jjweimer produced. But since it has four fit coefficients, and you have only four points, it requires selecting Manual Guesses. I also held the y0 coefficient and set it to zero.

And here's what I get from this sequence:

1) Duplicate wave0, logwave0 // I used wave0 and wave1 as the names for x-axis and y-axis
2) logwave0 = log(wave0)
3) Display wave1 vs wave0
4) I used the Interpolate item at the bottom of the Analysis menu to create a 200-point interpolated cubic spline wave

John Weeks
WaveMetrics, Inc.
support@wavemetrics.com
Graph1_0.png (19.58 KB) Graph1_0.png (19.58 KB) Graph1_0.png (19.58 KB)