What is the best way to find the linear regression of loglog data using numpy? When I plot the data and try
A = np.vstack([np.log10(X), np.ones(len(X))]).T
m, c = np.linalg.lstsq(A, np.log10(Y))[0]
ax.plot(X, [m*x + c for x in X], 'r')
where X and Y are the data lists, this is the result, obviously incorrect:
If you do a linear regression on
then in (x,y) coordinates you have
That is, you have fit a power law to your data. Change this
to