[SciPy-User] Vectorizing scipy.optimize.curve_fit
Fri Feb 1 17:07:52 CST 2013
I've run into a bit of a roadblock. I've got some model runs (x) in an Nx2
array where the first column is the input, and the second column is the
output. So in a single case, I'd do:
popt, pcov = scipy.optimize.curve_fit(myFit, x[:,0], x[:,1])
But how should I handle, say, 5000 model runs such that x.shape = (500, N,
2) and I want the 5000 results for popt?
popt_array = np.empty(5000, 2)
for r, layer in enumerate(model_runs):
popt, pcov = scipy.optimize.curve_fit(myFit, layer[:,0] layer[:,1])
popt_array[r] = popt
But is there a better (faster way)? The number of model runs and data
points may grow sustatially (~10^4 runs and 10^3 data points).
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the SciPy-User