小编mjo*_*mjo的帖子

scipy curve_fit 错误:函数调用的结果不是正确的浮点数组

我有一个 [x,y] 数据集,我想为其拟合一个函数。这是 x 和 y

parang = np.array([  61.1725  ,   62.140625,   62.93275 ,   63.701625,   65.89225 ,
     66.476875,   68.33525 ,   68.902375,   72.03975 ,   72.590375,
     73.144125,   73.670625,   80.36525 ,   80.80275 ,   87.505375,
     87.90375 ,  100.557875,  100.8915  ])

q      = np.array([-0.03699417, -0.03451252, -0.03851238, -0.0393034 , -0.04059193,
   -0.03941371, -0.04206476, -0.04153004, -0.04721763, -0.04667099,
   -0.03996427, -0.03872865, -0.05054322, -0.0466561 , -0.05476921,
   -0.05274144, -0.0474299 , -0.04974607])
Run Code Online (Sandbox Code Playgroud)

然后我想将一个函数拟合到数据中,如下所示:

def fq(x,bq,cuq):
    qval = bq*stndqu[0]*np.cos(np.radians(2*x))+cuq*stndqu[1]*np.sin(np.radians(2*x))
    print qval
    print qval.dtype
    return qval
Run Code Online (Sandbox Code Playgroud)

其中 'bq,cuq' 是我需要拟合的参数,stndqu 是我获得的全局参数:

stnd    = input(r'P ($\%$) and …
Run Code Online (Sandbox Code Playgroud)

scipy

9
推荐指数
1
解决办法
4万
查看次数

标签 统计

scipy ×1