i perform multidimensional odr scipy.odr . read api documentation, says multi-dimensionality possible, cannot make work. cannot find working example on internet , api crude , give no hints how proceed. here mwe: import numpy np import scipy.odr def linfit(beta, x): return beta[0]*x[:,0] + beta[1]*x[:,1] + beta[2] n = 1000 t = np.linspace(0, 1, n) x = np.full((n, 2), float('nan')) x[:,0] = 2.5*np.sin(2*np.pi*6*t)+4 x[:,1] = 0.5*np.sin(2*np.pi*7*t + np.pi/3)+2 e = 0.25*np.random.randn(n) y = 3*x[:,0] + 4*x[:,1] + 5 + e print(x.shape) print(y.shape) linmod = scipy.odr.model(linfit) data = scipy.odr.data(x, y) odrfit = scipy.odr.odr(data, linmod, beta0=[1., 1., 1.]) odrres = odrfit.run() odrres.pprint() it raises following exception: scipy.odr.odrpack.odr_error: number of observations not match which seems related matrix shapes, not know how must shape properly. know? firstly, in experience scipy.odr uses arrays, not matrices. library seems make large...
Comments
Post a Comment