I am running on Ubuntu 12.04 and using Gnuplot 4.4 patchlevel 3.
Tried fit a data file with a simple sin^2(kx)/(kx)^2 curve but usually it fits very badly, giving large fit error. The data looks like this:
558 0.2
561 0.205
564 0.19
567 0.185
570 0.189
573 0.181
576 0.172
579 0.167
582 0.163
585 0.143
588 0.13
591 0.111
594 0.096
597 0.086
600 0.07
603 0.055
606 0.047
609 0.04
612 0.032
615 0.029
618 0.023
621 0.021
624 0.02
627 0.022
630 0.022
633 0.02
636 0.022
639 0.023
642 0.025
645 0.026
648 0.026
651 0.024
654 0.025
657 0.02
660 0.021
663 0.021
666 0.014
669 0.013
672 0.012
675 0.012
678 0.01
681 0.012
684 0.009
687 0.013
690 0.012
693 0.012
If one tries to fit these data points using a curve like A*sq(sin(k*(x-561)))/sq(k*(x-561))+c via A,k,c (where sq(x)=x*x), gnuplot straight gives you an error of
Undefined value during function evaluation
In the above plot of data if you look closely, one finds that the peak of the data occures at 561 and at this point the above function becomes 0/0+c. May be that's what gnuplot means by undefined value. So if you use 560.5 instead it fits it nicely. Altough it makes me wonder whats wrong with 561. I guess something in the algorithum.
Gaurav Nirala
2012-11-15
datafile
Karl Ratzsch
2012-11-15
This seems to not be a fit problem, but a mathematical one. The sinc function (sin(x)/x)) has a value of one at x=0, while 0/0 generally is regarded as "undefined".
Hans-Bernhard Broeker
2012-11-15
The trick is that sin(x)/x is not actually the (complete) definition of sinc(x). To complete it, you need to actually define what's to happen at zero. In gnuplot, you would define it like this:
sinc(x) = (x != 0) ? sin(x)/x : 1.0
Closed as invalid because this is no bug
Hans-Bernhard Broeker
2012-11-15
Ethan Merritt
2013-03-01