I have to find the best solution for >10^7 equation systems with 5 equations in 2 variables each (5 measurements to find 2 parameters with the least amount of error in a long series). The following code (normally used to do curve fitting) does what I want:
#Create_example_Data n = 100 T_Arm = np.arange(10*n).reshape(-1, 5, 2) Erg = np.arange(5*n).reshape(-1, 5) m = np.zeros(n) c = np.zeros(n) #Run for counter in xrange(n): m[counter], c[counter] = np.linalg.lstsq(T_Arm[counter, :, :], Erg[counter, :])
Unfortunately it is too slow. Is there any way how to speed this code up significantly? I tried to vectorise it, but I did not succeed. Using the last solution as a initial guess might be a good idea as well. Using
scipy.optimize.leastsq did not speed it up as well.