我没试成功:
find_fit(data, quadratic_residues)
Run Code Online (Sandbox Code Playgroud)
我正在努力寻找最适合水流速率的数据:http://dl.getdropbox.com/u/175564/rate.png
---评论后编辑---
新代码:
var('x')
model(x) = x**2
find_fit((xlist, reqlist), model)
Run Code Online (Sandbox Code Playgroud)
错误消息:
Traceback (click to the left for traceback)
...
TypeError: data has to be a list of lists, a matrix, or a numpy array
Run Code Online (Sandbox Code Playgroud)
- -编辑
现在出现错误消息:
Traceback (click to the left for traceback)
...
ValueError: each row of data needs 2 entries, only 5 entries given
Run Code Online (Sandbox Code Playgroud)
mydata = [[1,3],[2,7],[3,13],[4,24]]
var('a,b,c')
mymodel(x) = a*x^2 + b*x + c
myfit = find_fit(mydata,mymodel,solution_dict=True)
points(mydata,color='purple') + plot(
mymodel(
a=myfit[a],
b=myfit[b],
c=myfit[c]
),
(x,0,4,),
color='red'
)
Run Code Online (Sandbox Code Playgroud)