I perform an ODR fit for given data points with x and y uncertainty with scipy.odr. For the fit result I would like to see the orthogonal distances of each point from the fit. This can be easily computed for a linear fit function but it can be more complicated for an arbitrary function. Since scipy.odr is minimizing these distances it has to compute them, so maybe one can directly access them but I did not find it in the documentation. Maybe I missed it? Any ideas?
So for the attached example code I would like to get an array of 100 elements containing the orthogonal distances and then e.g. plot a histogram.
import numpy as np
from scipy.odr import *
np.random.seed(1)
N = 100
x = np.linspace(0, 10, N)
y = 3*x - 1 + np.random.random(N)
sx = np.random.random(N)
sy = np.random.random(N)
def f(B, x):
return B[0]*x + B[1]
linear = Model(f)
mydata = RealData(x, y, sx=sx, sy=sy)
myodr = ODR(mydata, linear, beta0=[1., 2.])
myoutput = myodr.run()
myoutput.pprint()
