我想拟合不是完美球体的281 * 398 * 104矩阵的MR二进制数据,并找出球体的中心和半径以及误差。我知道LMS或SVD是适合球体的好选择。 我试图从sphereFit但matlab file exchange得到一个错误, >> sphereFit(data)
Warning: Matrix is singular to working precision.
> In
我想让我的数据适合一个函数。我一直在使用这个示例代码作为指导http://docs.scipy.org/doc/scipy/reference/tutorial/optimize.html#example-of-solving-a-fitting-problem。我的代码如下: from scipy.optimize import least_squares
import numpy as np
必须有一个更简单的方法来做到这一点,也欢迎优化方法。我有一个数组'Y'和许多参数必须调整,使得Y接近零(='X'),如MWE中给出的。是否有更好的程序来减少这种差异?这只是一个示例方程,可以有6个系数进行优化。 x = zeros(10,1)
y = rand(10,1)
for a=1:0.1:4
for b=2:0.1:5
for c = 3:0.1:6
T.A在学校向我展示了这个代码作为最小二乘拟合算法的一个例子。 import numpy as np
#return the coefficients (a0,..aN) of the fit y=a0+a1*x+..an*x^n
#with associated sigma dy
#x,y,dy are all np.arrays with dtype= np.float64
def f