[SciPy-User] Orthogonal distance regression in 3D

Владимир draft2008@bk...
Fri Mar 2 00:02:43 CST 2012

I'm working with orthogonal distance regression (scipy.odr).
I try to fit the curve to a point cloud (3d), but it doesn work properly, it returns wrong results

For example I want to fit the simple curve y = a*x + b*z + c to some point cloud (y_data, x_data, z_data)  
    def func(p, input):
    x,z = input
    x = np.array(x)
    z = np.array(z)
    return (p[0]*x + p[1]*z + p[2])

    initialGuess = [1,1,1]

    myModel = Model(func)
    myData = Data([x_data, z_daya], y_data)
    myOdr = ODR(myData, myModel, beta0 = initialGuess)
    out = myOdr.run()
    print out.beta 

It works perfectly in 2d dimension (2 axes), but in 3d dimension the results are not even close to real, moreover it is very sensitive to initial Guess, so it returns different result even if i change InitiaGuess from [1,1,1] to [0.99,1,1]

What do I do wrong?
Im not very strong in mathematics, but may be I should specify some additional parameters such as Jacobian matrix or weight matrix or something else?
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.scipy.org/pipermail/scipy-user/attachments/20120302/bd70d7cb/attachment.html 

More information about the SciPy-User mailing list