Question: Adjust using FFT

 What justifies the t-1; to achieve this result?

restart;
interface(warnlevel = 0, imaginaryunit = I, rtablesize = 12);
with(plots); with(plottools);
alias(FFT = DiscreteTransforms[FourierTransform], IFFT = DiscreteTransforms[InverseFourierTransform]);

Temp := [24.2, 28.4, 32.7, 39.7, 47.0, 53.0, 56.0, 55.0, 49.4, 42.2, 32.0, 27.1];
POI := seq([n, Temp[n]], n = 1 .. 12);

 p1 := pointplot([POI], labels = ["x~month", "y = Temperature~ºF"], labeldirections = [HORIZONTAL, VERTICAL], title = "Monthly Temperature", symbol = solidcircle, symbolsize = 22);
 display(p1);
P := 12; m0:= 5; N := 12; evalb(N > 2*m0+1);

dd := FFT(<Temp>, normalization = full);
ddf := evalf(dd);
evalf(ddf, 3);
Amplitude_ddf := abs(ddf);
evalf(Amplitude_ddf, 4);

g1 := [seq([[k-1, 0], [k-1, Amplitude_ddf[k]]], k = 1 .. op(Amplitude_ddf)[1])];
plot(g1, thickness = 12, color = blue, title = "DFT, amplitude spectrum");

dh := proc (t) options operator, arrow; ddf[1]+add(ddf[k+1]*exp((2*I)*Pi*k*(t-1)/P), k = 1 .. m0)+add(conjugate(ddf[k+1])*exp(-(2*I)*Pi*k*(t-1)/P), k = 1 .. m0) end proc;

p2 := plot(dh(t), t = 0 .. P, color = red, thickness = 5, linestyle = 1, transparency = .8);
plots[display](p1, p2);

y := proc (x) options operator, arrow; Statistics[Fit](a*sin(b*x+c)+f, [POI], [x], initialvalues = [a = 2, b = 1, c = 1, f = 10], output = leastsquaresfunction) end proc;

p3 := plot(y(t), t = 0 .. 12, color = blue);
plots[display](p1, p2, p3);
y(z);

 

FitwithFFT.mw

GRACIAS

Please Wait...