[SciPy-User] Orthogonal distance regression in 3D

Владимир draft2008 at bk.ru
Mon Mar 5 05:26:39 EST 2012


02 марта 2012, 15:49 от Robert Kern <robert.kern at gmail.com>:
> On Fri, Mar 2, 2012 at 06:02, Владимир <draft2008 at bk.ru> wrote:
> > Hello!
> > 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)
> >
> >     myOdr.set_job(fit_type=0)
> >
> >     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?
>
> Can you provide a complete runnable example including some data? Note
> that if you do not specify any errors on your data, they are assumed
> to correspond to a standard deviation of 1 for all dimensions. If that
> is wildly different from the actual variance around the "true"
> surface, then it might lead the optimizer astray.
>
> --
> Robert Kern
>

I wonder why when I change the initial guess the results changes too. As it, the result depends on the initial guess directly. This is wrong.

Here is an example (Sorry for the huge array of data, but its important to show what happens on it)

import numpy as np
from scipy.odr import *
from math import *

x_data = [26.6, 25.5, 26.2, 25.5, 24.9, 24.9, 30.3, 30.4, 35.7, 25.8, 34.7, 32.8, 36.5, 20.4, 24.2, 25.4, 24.5, 23.4, 20.9, 33.3, 27.0, 28.1, 21.7, 24.47, 22.2, 22.43, 23.43, 22.27, 22.27, 28.63, 28.7, 29.1, 30.0, 29.77, 26.93, 27.7, 27.83, 28.23, 31.2, 30.3, 32.13, 27.6, 33.73, 29.07, 29.0, 29.77, 32.7, 32.93, 32.65, 22.63, 25.13, 27.77, 19.77, 31.52, 33.0, 34.1, 33.23, 35.6, 33.83, 32.4, 33.1, 31.08, 31.5, 32.6, 33.67, 31.6, 34.1, 32.92, 34.63, 32.4, 30.1, 33.8, 35.6, 31.9, 29.8, 35.7, 34.4, 34.6, 36.0, 28.63, 27.47, 29.93, 24.17, 24.1, 23.8, 27.2, 26.1, 31.12, 25.17, 29.35, 31.67, 29.67, 30.13, 30.1, 30.27, 30.73, 31.1, 33.33, 28.75, 26.67, 30.37, 28.6, 24.75, 30.5, 29.63, 31.0, 30.15, 29.85, 12.85, 34.2, 20.67, 20.73, 19.83, 13.6, 20.0, 19.45, 21.25, 22.05, 14.27, 28.37, 29.85, 32.8, 32.42, 31.05, 33.15, 32.25, 32.38, 32.42, 34.87, 31.97, 31.98, 33.0, 32.03, 34.4, 34.05, 21.43, 19.92, 22.0, 22.1, 27.57, 21.1, 23.77, 21.63, 26.77, 22.93, 25.67, 30.6, 25.37, 26.7, 31.03, 27.7, 31.13, 29.35, 27.33, 28.6, 26.9, 31.9, 9.37, 30.6, 26.93, 29.95, 31.6, 30.7, 24.6, 31.4, 23.47, 26.25, 33.6, 25.0, 33.8, 31.9, 22.7, 25.23, 20.1, 17.55, 18.45, 17.9, 23.13, 18.33, 18.5, 19.38, 19.27, 22.6, 22.37, 22.97, 25.07, 26.37, 17.43, 21.0, 18.23, 32.83, 30.52, 19.3, 20.1, 5.6, 26.23, 26.95, 26.35, 26.47, 28.8, 28.73, 25.45, 26.53, 23.45, 20.6, 24.47, 23.9, 13.35, 30.47, 29.67, 31.15, 29.15, 29.63, 28.58, 29.0, 31.7, 28.57, 29.58, 29.1, 22.48, 30.0, 26.15, 26.93, 28.77, 30.1, 24.03, 28.77, 29.4, 29.3, 29.95, 27.0, 29.05, 25.62, 26.8, 25.85, 22.42, 21.77, 28.2, 21.0, 20.8, 28.8, 28.7, 24.8, 27.87, 29.4, 29.1, 28.33, 27.6, 32.93, 33.3, 33.17, 31.4, 30.37, 34.8, 25.0, 23.48, 33.4, 30.23, 29.07, 28.9, 26.9, 31.77, 25.57, 19.67, 30.5, 19.97, 18.63, 26.35, 19.23, 31.2, 30.37, 30.6, 31.92, 27.35, 28.15, 28.67, 32.6, 20.83, 29.0, 28.2, 20.7, 20.6, 30.1, 30.4, 30.83, 31.0, 30.7, 29.77, 31.17, 31.63, 31.37, 32.2, 31.3, 20.0, 18.9, 32.4, 32.5, 32.3, 32.53, 21.67, 22.17, 22.4, 21.7, 23.8, 26.1, 20.7, 23.5, 21.5, 15.9, 24.3, 21.7, 25.5, 26.6, 23.3, 14.0, 20.2, 21.0, 25.4, 21.4, 28.4, 16.2, 22.2, 22.8, 21.8, 24.4, 23.6, 21.7, 31.5, 27.3, 27.7, 23.7, 20.9, 22.5, 21.9, 18.1, 20.9, 13.3, 12.9, 25.0, 22.2, 21.4, 31.6, 24.2, 15.0, 15.3, 20.1, 24.5, 21.3, 21.4, 22.8, 27.9, 29.5, 18.8, 18.1, 17.8, 23.5, 19.4, 18.8, 13.8, 17.3, 19.6, 22.1, 22.2, 20.3, 10.7, 22.2, 10.3, 22.4, 16.1, 22.9, 28.0, 28.8, 25.6, 29.7, 29.7, 20.8, 21.0, 27.9, 23.8, 24.1, 21.1, 24.1, 32.6, 21.6, 28.9, 26.9, 5.1, 31.3, 21.2, 22.6, 24.2, 31.1, 24.8, 30.3, 27.3, 26.3, 20.9, 22.2, 29.7, 25.0, 25.9, 31.0, 31.0, 29.0, 25.0, 25.0, 30.2, 28.1, 29.5, 26.8, 27.0, 30.4, 30.8, 31.5, 31.0, 30.7, 32.2, 21.25, 30.35, 31.15, 33.25, 28.1, 33.1, 26.3, 33.05, 31.65, 31.9, 27.15, 28.4, 28.1, 29.9, 31.8, 33.45, 30.3, 31.75, 26.15, 23.6, 23.85, 28.0, 29.5, 25.55, 24.6, 22.25, 27.2, 27.95, 25.0, 29.7, 24.95, 26.6, 22.85, 25.0, 27.55, 26.0, 21.1, 25.95, 29.4, 27.8, 32.6, 25.2, 25.05, 31.0, 27.55, 27.95, 32.15, 30.85, 32.75, 31.05, 31.7, 31.25, 32.55, 30.9, 31.8, 31.45, 29.85, 29.75, 31.75, 32.35, 23.15, 28.3, 28.95, 26.8, 27.55, 28.45, 28.5, 27.45, 17.0, 22.8, 26.05, 27.8, 28.1, 29.25, 27.35, 27.2, 27.85, 27.55, 26.75, 29.0, 27.6, 29.25, 30.45, 28.05, 24.5, 23.15, 27.9, 28.55, 27.85, 23.6, 28.7, 29.55, 27.35, 28.25, 26.7, 25.95, 28.75, 27.6, 27.4, 30.0, 26.7, 28.1, 27.8, 28.0, 32.15, 27.25, 32.0, 33.9, 19.7, 30.15, 29.8, 27.0, 24.65, 22.15, 23.3, 24.0, 23.85, 26.35, 26.35, 26.1, 25.75, 27.7, 26.35, 26.25, 27.9, 29.05, 27.85, 26.0, 26.6, 25.3, 24.75, 24.85, 23.0, 28.95, 22.9, 24.15, 26.95, 21.8, 26.2, 28.5, 22.5, 24.75, 24.45, 30.4, 26.15, 19.85, 18.55, 26.3, 29.8, 26.05, 13.9, 27.65, 30.8, 24.0, 19.6, 21.7, 25.05, 26.65, 21.6, 28.2, 28.65, 25.15, 20.55, 21.55, 23.4, 23.6, 22.15, 21.2, 24.5, 21.7, 21.45, 23.1, 24.1, 22.2, 17.35, 22.05, 22.05, 23.75, 25.15, 25.75, 21.05, 27.43, 22.45, 26.25, 27.1, 27.15, 25.55, 23.0, 26.45, 25.95, 29.2, 25.55, 25.15, 26.45, 27.15, 24.75, 25.7, 32.65, 31.15, 23.85, 27.0, 27.3, 25.15, 25.55, 29.2, 24.0, 25.0, 28.2, 27.95, 24.65, 25.0, 25.6, 25.05, 24.7, 26.9, 23.6, 24.15, 19.75, 20.55, 27.7, 23.75, 24.8, 21.2, 31.2, 26.3, 30.8, 32.4, 22.2, 21.5, 27.4, 26.3, 30.4, 21.0, 23.3, 28.1, 16.65, 26.15, 17.9, 21.35, 21.1, 20.65, 30.4, 23.0, 25.7, 26.7, 22.7, 29.4, 25.9, 29.4, 21.55, 26.3, 25.1, 26.3, 32.7, 27.9, 31.4, 29.6, 31.4, 31.9, 31.45, 32.55, 31.35, 31.65, 29.75, 25.75, 26.1, 28.7, 30.75, 27.4, 24.9, 2.7, 27.2, 26.35, 28.2, 27.5, 28.45, 27.25, 30.5, 28.9, 30.8, 26.45, 24.5, 31.2, 26.45, 24.85, 25.1, 26.0, 25.5, 25.2, 25.6, 24.0, 30.8, 31.8, 31.6, 27.5, 9.2, 22.2, 23.3, 28.1, 30.8, 31.3, 3.5, 29.2, 31.4, 25.3, 29.7, 28.2, 25.6, 32.9, 24.0, 23.5, 27.5, 24.9, 22.4, 28.1, 26.2, 23.9, 23.9, 7.8]

z_data = [75.5, 76.7, 78.7, 77.4, 79.5, 73.6, 80.0, 77.3, 46.9, 61.4, 40.3, 56.3, 45.3, 67.0, 80.4, 85.1, 82.5, 69.4, 74.8, 91.0, 79.6, 84.2, 92.5, 73.0, 91.4, 86.0, 76.0, 78.0, 82.3, 37.7, 71.5, 39.3, 60.8, 60.2, 34.3, 56.8, 57.0, 41.0, 51.3, 55.2, 42.1, 36.3, 39.2, 62.9, 77.3, 55.0, 44.0, 44.3, 40.8, 49.2, 72.0, 61.6, 83.6, 46.2, 24.7, 22.8, 17.2, 20.0, 25.9, 28.5, 19.2, 34.4, 29.7, 27.2, 22.0, 29.2, 21.1, 28.7, 23.4, 35.9, 37.8, 17.2, 17.9, 31.7, 39.0, 18.4, 23.3, 23.1, 14.0, 77.9, 72.3, 32.3, 82.0, 78.3, 82.7, 65.1, 54.2, 59.2, 70.7, 23.1, 22.0, 25.0, 29.0, 28.3, 27.8, 27.9, 27.1, 27.7, 48.6, 45.3, 45.0, 55.0, 63.0, 46.8, 55.4, 46.5, 32.1, 61.9, 50.2, 42.4, 34.5, 91.0, 85.3, 76.5, 94.8, 91.7, 76.2, 31.4, 66.9, 27.5, 28.0, 21.0, 14.2, 20.6, 21.6, 24.3, 18.8, 24.2, 13.8, 19.1, 35.8, 19.6, 25.0, 19.4, 19.3, 89.8, 88.1, 91.7, 84.5, 46.6, 88.9, 81.2, 81.0, 57.9, 77.9, 67.0, 31.8, 57.0, 60.5, 45.0, 57.6, 44.5, 36.2, 41.3, 45.7, 49.3, 41.9, 61.7, 32.2, 71.2, 45.0, 32.6, 31.0, 49.0, 29.8, 15.1, 38.5, 27.0, 38.5, 35.8, 4.05, 90.7, 68.7, 85.1, 90.9, 92.7, 94.4, 89.3, 92.2, 95.5, 91.7, 92.9, 91.5, 86.7, 64.0, 74.1, 50.0, 91.8, 87.3, 86.1, 40.8, 40.7, 89.0, 92.9, 93.7, 58.1, 50.5, 58.4, 53.6, 30.7, 43.3, 54.5, 51.0, 96.4, 85.2, 87.0, 60.5, 49.7, 40.0, 51.0, 20.1, 21.2, 44.5, 41.1, 43.3, 38.1, 47.2, 42.7, 52.2, 38.4, 21.9, 56.0, 55.0, 48.9, 22.7, 46.5, 46.5, 22.4, 39.2, 22.0, 53.3, 40.6, 51.1, 26.6, 53.0, 75.0, 77.8, 56.0, 78.0, 74.8, 48.7, 50.6, 19.5, 38.8, 43.1, 61.9, 50.1, 49.8, 27.2, 28.3, 28.3, 34.2, 33.8, 26.6, 71.3, 62.5, 25.6, 40.4, 26.9, 30.1, 24.0, 25.9, 43.5, 80.0, 39.2, 88.0, 87.0, 44.5, 65.1, 34.6, 30.1, 33.4, 34.4, 35.9, 38.5, 42.1, 48.5, 56.0, 37.2, 36.5, 88.5, 73.0, 35.1, 34.7, 28.0, 29.6, 30.7, 30.6, 30.9, 29.9, 30.3, 29.8, 31.0, 88.3, 88.4, 29.8, 29.8, 27.9, 29.2, 73.2, 85.0, 91.4, 83.6, 42.5, 44.4, 57.2, 41.4, 32.5, 60.7, 41.2, 45.9, 37.4, 46.2, 44.2, 45.9, 43.3, 46.2, 46.5, 37.4, 66.4, 62.3, 75.8, 19.4, 15.4, 15.2, 73.8, 78.5, 38.0, 33.2, 32.5, 89.5, 92.2, 83.6, 77.0, 61.7, 88.8, 72.9, 65.6, 30.7, 78.2, 52.4, 46.3, 76.3, 52.1, 53.0, 44.8, 35.5, 40.0, 41.3, 41.1, 32.8, 45.6, 42.9, 43.3, 41.8, 86.8, 81.2, 73.0, 69.7, 65.3, 59.5, 78.5, 58.3, 86.1, 80.0, 74.7, 82.2, 90.8, 67.2, 69.2, 42.0, 56.5, 35.3, 44.7, 51.6, 37.5, 58.3, 45.0, 45.3, 18.2, 70.6, 51.3, 55.2, 68.5, 63.0, 65.6, 95.7, 41.8, 73.7, 67.2, 58.9, 51.4, 57.1, 37.0, 48.9, 61.9, 79.5, 61.6, 53.0, 45.9, 53.4, 55.1, 50.9, 60.2, 55.2, 50.4, 39.3, 44.4, 55.9, 52.4, 45.2, 45.4, 32.8, 37.4, 41.3, 25.9, 22.7, 82.7, 36.3, 45.4, 55.2, 73.7, 44.6, 81.9, 68.0, 35.6, 39.3, 80.9, 33.9, 26.9, 29.8, 31.1, 23.3, 49.9, 30.9, 89.1, 37.4, 64.5, 60.8, 53.4, 76.3, 80.4, 77.1, 56.8, 65.8, 75.8, 25.2, 82.7, 50.6, 69.9, 78.9, 78.9, 57.8, 90.2, 65.9, 57.0, 59.0, 36.3, 73.4, 71.8, 56.5, 77.0, 73.9, 66.9, 59.4, 51.3, 46.1, 52.0, 53.2, 50.8, 57.6, 57.7, 48.0, 59.7, 56.8, 55.4, 45.3, 74.8, 43.9, 46.0, 49.1, 43.8, 43.9, 43.9, 52.5, 38.5, 24.2, 60.8, 81.2, 32.6, 12.5, 15.8, 24.8, 67.9, 69.0, 80.0, 66.4, 86.2, 63.8, 71.0, 72.8, 86.0, 93.0, 52.0, 74.7, 68.3, 74.1, 63.6, 70.1, 80.6, 73.3, 78.9, 80.9, 61.3, 82.3, 69.2, 60.4, 82.7, 80.4, 75.6, 81.1, 54.7, 62.6, 56.7, 41.1, 78.7, 67.1, 70.3, 75.4, 89.0, 74.4, 56.0, 93.4, 63.8, 61.7, 81.5, 82.9, 76.5, 80.1, 73.1, 71.4, 66.6, 53.4, 73.8, 82.6, 60.2, 79.1, 86.8, 80.7, 93.4, 43.9, 85.3, 78.3, 32.8, 47.3, 48.3, 48.6, 67.5, 76.1, 82.2, 35.3, 58.2, 58.6, 62.3, 65.2, 40.6, 67.9, 62.5, 49.2, 28.2, 85.6, 47.6, 94.8, 82.9, 84.6, 94.7, 49.2, 69.5, 81.5, 86.9, 74.7, 68.9, 70.7, 81.9, 73.5, 70.8, 76.2, 82.5, 78.7, 75.3, 76.6, 80.5, 78.9, 65.3, 62.6, 90.4, 59.2, 63.6, 50.0, 72.6, 47.6, 48.2, 48.3, 47.7, 57.1, 51.5, 75.7, 48.8, 83.1, 73.4, 67.0, 64.8, 80.4, 88.9, 34.7, 40.2, 87.4, 78.2, 69.2, 84.8, 83.4, 37.0, 63.3, 62.9, 6.5, 76.2, 87.9, 67.9, 68.3, 77.0, 65.3, 57.1, 67.2, 63.5, 64.8, 64.0, 39.0, 82.5, 64.0, 69.1, 53.4, 76.6, 34.7, 54.0, 89.7, 84.0, 57.6, 66.3, 54.0, 77.6, 84.5, 75.2, 46.5, 77.2, 85.2, 74.0, 69.3, 61.7, 42.7, 82.7, 74.7, 57.2, 78.7, 36.7, 56.2, 47.8, 84.8, 42.6, 48.1, 53.6, 34.0, 38.5, 31.5, 28.9, 29.8, 27.6, 27.7, 27.1, 25.3, 32.6, 59.0, 41.1, 69.8, 49.4, 47.2, 50.2, 81.4, 70.0, 70.0, 78.2, 68.6, 76.7, 63.6, 76.5, 62.5, 66.4, 57.2, 87.6, 82.8, 53.9, 73.0, 78.5, 63.5, 65.3, 67.7, 94.5, 84.5, 77.9, 57.2, 47.8, 70.0, 99.4, 64.0, 100.0, 72.8, 79.5, 88.1, 85.4, 42.1, 59.2, 62.9, 71.5, 71.7, 75.2, 100.0, 52.3, 88.4, 99.8, 71.9, 90.0, 96.1, 69.0, 74.3, 99.7, 85.8, 70.4]

y_data = [6.33, 0.73, 12.6, 1.01, 5.95, 2.89, 13.5, 11.5, 360.0, 52.4, 614.0, 477.0, 492.0, 1.51, 1.93, 11.2, 2.16, 4.51, 1.47, 53.0, 0.9, 2.17, 1.7, 5.2, 1.5, 3.6, 9.9, 12.2, 6.8, 35.3, 7.8, 26.7, 10.8, 6.9, 7.7, 15.3, 10.8, 22.9, 16.2, 19.4, 52.6, 25.1, 95.5, 5.6, 4.1, 23.1, 161.4, 72.3, 38.6, 22.0, 5.7, 12.1, 2.2, 77.9, 328.0, 349.1, 323.9, 516.1, 197.7, 172.7, 339.3, 84.1, 194.6, 109.1, 221.1, 169.8, 553.0, 97.1, 294.9, 110.7, 58.4, 857.0, 532.5, 106.5, 51.3, 594.0, 246.4, 406.3, 727.5, 12.7, 11.2, 25.5, 6.5, 5.8, 4.1, 19.5, 40.5, 7.1, 5.1, 545.6, 421.9, 285.1, 317.8, 294.6, 339.6, 308.7, 312.8, 301.2, 26.3, 38.4, 39.3, 51.1, 3.3, 56.1, 33.3, 48.8, 150.9, 11.1, 16.5, 53.9, 1.2, 0.91, 1.7, 4.6, 0.53, 0.59, 11.6, 149.4, 1.3, 410.8, 418.3, 679.4, 731.3, 705.9, 660.1, 543.2, 871.6, 544.8, 1651.5, 1075.5, 226.1, 854.4, 471.2, 669.7, 709.8, 2.1, 1.6, 1.2, 1.1, 7.2, 0.79, 1.1, 1.5, 5.6, 2.9, 3.7, 58.5, 21.1, 9.6, 60.7, 25.8, 41.9, 62.6, 68.7, 56.6, 23.6, 118.8, 3.0, 202.1, 6.4, 40.4, 261.5, 139.4, 21.8, 107.2, 265.5, 116.6, 154.8, 97.5, 224.4, 550.9, 1.2, 12.6, 1.7, 0.97, 1.5, 0.96, 1.1, 0.29, 0.13, 0.62, 0.16, 0.52, 6.3, 30.4, 2.8, 46.0, 1.1, 0.47, 2.2, 63.0, 43.5, 0.46, 0.31, 0.05, 113.1, 18.2, 5.1, 11.7, 262.5, 43.4, 20.2, 30.9, 2.1, 1.6, 0.94, 4.9, 3.3, 91.1, 39.0, 133.3, 48.2, 69.1, 112.6, 112.1, 251.8, 33.8, 108.2, 45.2, 31.0, 82.9, 41.7, 36.7, 75.9, 49.2, 20.8, 80.3, 47.9, 67.7, 55.0, 37.6, 120.4, 50.6, 42.2, 13.8, 4.7, 4.2, 25.0, 0.56, 2.4, 104.7, 24.4, 300.4, 70.4, 40.5, 5.7, 30.9, 8.2, 149.7, 278.5, 288.7, 38.2, 123.0, 686.5, 1.7, 10.9, 939.1, 83.8, 538.5, 259.8, 485.8, 996.9, 10.0, 2.7, 50.4, 0.71, 0.65, 8.9, 1.4, 82.5, 80.8, 92.6, 98.7, 23.4, 34.2, 18.8, 55.4, 2.8, 39.5, 24.0, 0.82, 7.9, 75.9, 98.4, 108.5, 82.8, 122.0, 138.9, 157.9, 161.5, 174.0, 161.7, 163.7, 2.4, 0.75, 206.2, 187.8, 168.3, 157.6, 2.9, 0.96, 1.4, 1.03, 24.4, 80.8, 13.6, 66.0, 156.5, 1.8, 38.6, 43.0, 150.7, 81.4, 140.3, 18.2, 37.3, 31.6, 50.2, 86.1, 5.1, 24.6, 6.5, 150.8, 288.2, 481.6, 5.0, 5.9, 179.2, 248.6, 150.2, 1.3, 1.4, 4.6, 24.9, 4.8, 4.6, 0.98, 3.2, 211.1, 2.2, 14.6, 45.0, 3.4, 4.8, 5.3, 22.0, 53.4, 38.2, 29.5, 69.2, 179.9, 29.7, 18.6, 26.0, 28.8, 1.2, 0.9, 7.3, 1.6, 3.5, 22.7, 0.81, 15.1, 0.76, 0.46, 5.5, 0.29, 0.76, 2.4, 40.1, 173.8, 32.9, 69.7, 24.0, 7.7, 30.8, 15.0, 80.0, 68.4, 428.6, 16.3, 82.4, 42.3, 12.5, 2.7, 6.7, 0.23, 79.2, 1.3, 4.9, 12.8, 26.5, 11.9, 107.9, 27.5, 10.0, 1.1, 26.1, 54.0, 74.8, 26.3, 72.8, 71.3, 34.1, 80.5, 33.9, 201.8, 138.2, 35.8, 40.0, 65.4, 72.5, 96.6, 58.3, 31.0, 624.9, 1047.6, 0.41, 112.6, 66.5, 19.4, 1.1, 75.1, 0.68, 3.8, 28.2, 126.1, 0.91, 50.8, 62.4, 45.9, 137.7, 575.8, 78.1, 36.5, 0.41, 24.8, 4.8, 6.4, 8.8, 1.4, 1.4, 1.1, 7.3, 9.7, 6.2, 11.5, 1.1, 5.4, 5.1, 1.7, 77.8, 19.4, 0.53, 4.3, 29.5, 2.8, 225.9, 3.0, 14.7, 10.8, 3.3, 11.0, 6.8, 11.4, 73.3, 112.3, 21.6, 24.2, 34.0, 12.5, 25.2, 46.7, 12.7, 261.0, 2.5, 50.0, 0.3, 77.6, 126.0, 126.6, 87.0, 14.2, 77.0, 31.2, 19.4, 182.1, 19.4, 5.6, 63.6, 1316.0, 620.7, 744.8, 3.6, 5.9, 3.0, 3.4, 1.5, 9.6, 12.3, 6.3, 0.84, 50.0, 50.5, 1.24, 15.3, 1.6, 12.5, 9.0, 8.0, 9.6, 1.3, 1.3, 11.5, 3.7, 3.4, 13.9, 1.9, 1.4, 9.1, 1.4, 41.3, 31.7, 40.5, 191.4, 1.9, 15.7, 4.5, 3.5, 0.37, 2.0, 6.5, 1.0, 5.6, 5.7, 2.1, 1.7, 7.5, 1.3, 12.3, 6.8, 9.9, 52.9, 2.8, 2.5, 11.4, 7.1, 5.1, 4.6, 1.0, 53.4, 0.84, 1.08, 316.4, 63.6, 20.5, 50.3, 7.5, 0.91, 1.8, 123.8, 8.4, 15.3, 6.7, 4.4, 172.4, 3.6, 5.3, 74.7, 377.5, 0.91, 35.4, 2.0, 2.0, 1.9, 2.1, 17.5, 1.5, 2.1, 1.2, 2.5, 4.6, 4.1, 1.2, 1.5, 5.3, 1.9, 0.85, 1.3, 2.2, 3.7, 1.1, 0.75, 4.9, 10.4, 1.1, 21.8, 8.3, 60.5, 3.6, 85.4, 56.6, 88.5, 55.5, 24.5, 75.2, 4.3, 76.3, 0.93, 4.2, 7.65, 25.1, 3.5, 0.83, 434.8, 255.1, 0.77, 2.2, 7.2, 1.1, 1.3, 460.0, 6.5, 33.8, 9.6, 5.8, 0.85, 7.5, 7.8, 3.4, 17.9, 22.0, 4.4, 16.8, 4.7, 5.1, 9.7, 3.5, 16.5, 2.8, 80.2, 6.0, 139.2, 18.6, 1.27, 2.3, 18.5, 4.1, 5.4, 1.7, 7.9, 3.3, 6.1, 5.5, 1.4, 2.7, 14.5, 12.8, 60.3, 3.4, 2.2, 5.8, 6.3, 144.3, 39.6, 37.3, 3.2, 92.4, 43.0, 16.3, 261.8, 102.0, 250.9, 321.2, 375.1, 447.3, 493.1, 601.4, 543.1, 544.5, 30.7, 46.8, 14.8, 18.3, 76.2, 18.1, 7.8, 0.09, 3.3, 2.8, 2.3, 19.1, 6.2, 1.9, 43.2, 11.8, 16.7, 8.1, 1.9, 16.9, 2.9, 1.6, 2.4, 6.8, 2.3, 1.97, 4.23, 10.47, 83.56, 81.33, 24.98, 5.58, 0.12, 1.16, 2.01, 32.6, 43.62, 193.7, 0.13, 13.56, 13.3, 37.79, 19.85, 13.25, 2.38, 375.7, 0.79, 15.84, 12.19, 2.94, 0.63, 5.68, 5.68, 12.54, 6.73, 0.66]

def funcReturner(p, input):
	input = np.array(input) 	
	x = input[0]
	z = input[1]
	return 10**(p[0]*x + p[1]*z +p[2])
	
myModel = Model(funcReturner)
myData = Data([x_data,z_data], y_data)
myOdr = ODR(myData, myModel, beta0=[0.04, -0.02,  1.75])
myOdr.set_job(fit_type=0)
out = myOdr.run()
result = out.beta	

print "Optimal coefficients: ", result

I tryed to specify sx, sy, we, wd, delta, everything: and I get the better results, but they are still not what I need. And they are still depends directly on initial guess as well.
If I set initial guess to [1,1,1], it fails to find any close solution and returns totally wrong result with huge Residual Variance like 3.21014784829e+209



More information about the SciPy-User mailing list