Q: Performance difference Python/Matlab curve fitting When fitting a very simple function to some randomly created data I came across the fact that Python seems to outperform Matlab by roughly two orders of magnitude. 
Now, this might depend on the specific implementations and also on the function used for this particular fit, however, I still find it strange that there is such a massive difference. I'd be grateful if anybody could tell me how this comes about.
Matlab (also used to create data and write to file, which is then read by python):
% Write data to file to be able to compare across languages
x = 0:9;
x = repmat(x', 1, 100);
y = x.^2;
y = y+randn(10, 100);
dlmwrite('y_mat.csv',y);
% Fit and time execution
tic
D = zeros(1, 100);
a = zeros(1, 100);
ft = fittype('4*D*x^a');
for i = 1:100
    f = fit(x(:, i),y(:, i), ft);
    a(i) = f.a;
    D(i) = f.D;
end
toc

Python:
import time
import numpy as np
from scipy import optimize
start_time = time.time()
data = np.loadtxt("y_mat.csv", delimiter=',');
def func(t, D, a):
    return 4*D*t**a
DA = np.zeros([numParticles, 2])
for i in range(0, numParticles):
    x = np.arange(10) 
    y = data[:,i] 
    popt, pcov = optimize.curve_fit(func, x, y)
    DA[i, ] = popt
print("--- %s seconds ---" % (time.time() - start_time))

