Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

find_fit error with trig data

This is using the example built-in to the help,

set_random_seed(0)
data = [(i, 1.2 * sin(0.5*i-0.2) + 0.1 * normalvariate(0, 1)) for i in xsrange(0, 4*pi, 0.2)]
var('a, b, c, x')
model(x) = a * sin(b * x - c)
sol = find_fit(data, model)
f(x) = model(a=sol[0].rhs(), b=sol[1].rhs(),c=sol[2].rhs())
p=plot(f(x),(x,0,13))
p+=list_plot(data,color='red')
show(p)
data

This is all good, except change 4*pi to 13 and find_fit no longer works. Any idea why?
C