Question: Fit data to sine function off

I tried to fit a sin function to some data using Statistics[Fit] however the result either didn't work properly or worked differently from the way I expected it to work.

a2 is the calculated function from Statistics[Fit] and a3 is some quickly inserted values that provides a more satisfying result. 

Why is a better fitting line not found?


restart; gc()

X := [73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91]:

Y := [35, 35, 36, 41, 47, 42, 43, 37, 34, 28, 28, 30, 27, 33, 35, 38, 42, 42, 40]:

``

with(plots):

with(Statistics):

a1 := pointplot(zip(`[]`, X, Y)):

f := Statistics:-Fit(a*sin(b*x+c)+d, X, Y, x)

HFloat(2.1212360930685046)*sin(HFloat(1.0274743698606499)*x-HFloat(2.6022740116723866))+HFloat(36.46562486953954)

(1)

a2 := plot(f, x = 72 .. 92):

``

display(a1, a2)

 

f1 := 8*sin(.5*x-5.5)+36

8*sin(.5*x-5.5)+36

(2)

a3 := plot(f1, x = 72 .. 92):

``

plots:-display(a1, a3)

 

``


Download Fitting-Sine-off.mw

Please Wait...