|
From: <pl...@pi...> - 2013-10-21 09:23:24
|
On 10/21/13 02:40, sfeam wrote: > On Sunday, 20 October 2013 08:22:51 PM you wrote: >> Hi, >> >> I have a curious glitch in plotting the sum of three cosines. >> >> set samples 1700 >> >> twopi=2*pi >> c1(x)=a1*cos(twopi*(x-yz+ph1)/p1) >> c2(x)=a2*cos(twopi*(x-yz+ph2)/p2) >> c3(x)=a3*cos(twopi*(x-yz+ph3)/p3) >> f3(x)=c1(x)+c2(x)+c0+c3(x) >> >> a1=a2=a3=1; c0=3.; yz=1958; p1=1.0;p2=0.5;p3=.25; ph1=ph2=ph3=.1 >> a3=1;ph3=0.1;p3=0.25 >> >> fit f3(x) datafile u (($1)/365.25+1945):2 via >> a1,a2,c0,ph1,ph2,p2,p3,a3,ph3 >> >> plot datafile u (($1)/365.25+1945):(f3($1)) w l > > I suspect that despite your large value for "set sample" > you are still sampling too coarsely by a factor of a thousand or so. > The smooth curve you see is probably an aliasing artifact. > > Ethan > > > > >> >> data either side of that point seem fine and if I use it directly with >> plot "-" I don't get the glitch. >> >> >> Closing gnuplot session and repeating the plot from file gives same >> result seen in attached png flie. >> >> For the benefit of the list that don't see the file, it looks like a >> cosine ranging -0.07 and + 0.014 pk to pk with some small ripple with >> sporadic spikes ranging from 0.025 to 0.075 , glitches are just single >> points. >> >> Irrespective of the actual data fed in , I fail to see how the sum of >> cosines can have such glitches. >> >> >> If anyone can explain how that could happen I'd like to know, otherwise >> it looks like a bug. >> >> Thanks, Peter. >> >> >> >> >> >> plot "-" u (($1)/365.25+1945):(f3($1)) w l >> >> 22629 381.81 >> 22636 381.88 >> 22643 381.65 >> 22650 382.62 >> 22657 382.25 >> 22664 381.37 >> 22678 383.09 >> 22685 383.59 >> 22692 384.19 >> 22699 383.76 >> 22706 383.71 >> 22713 383.64 >> 22720 384.28 >> e >> >> >> >> >> Final set of parameters Asymptotic Standard Error >> ======================= ========================== >> >> a1 = 0.0486237 +/- 0.001654 (3.402%) >> a2 = 0.0265777 +/- 0.001788 (6.728%) >> c0 = 0.00416031 +/- 0.001169 (28.1%) >> ph1 = -0.0557476 +/- 0.005409 (9.703%) >> ph2 = 0.163801 +/- 0.009924 (6.059%) >> p2 = 0.49982 +/- 0.0001585 (0.03171%) >> p3 = 0.258274 +/- 0.0005954 (0.2305%) >> a3 = -0.00192983 +/- 0.00202 (104.7%) >> ph3 = -0.923156 +/- 0.06458 (6.996%) >> >> G N U P L O T >> Version 4.7 patchlevel 0 last modified 2012-10-16 >> Build System: Linux i686 >> >> > HI, aliasing was my first thought too but set samples 1700000; replot same thing. what I intend to be plotting is plot datafile u (($1)/365.25+1945):(f3($1/365.25+1945)) w l That works. but while fiddling I saw these glitches and went to see where they were coming from. What looks buggy to me is that _whatever_ numbers I throw at it , the sum of three cosines should never have spikes. Is this some internal underflow/overflow problem? Thanks Ethan, |