score:0

Accepted answer

You have two problems. One is that quad returns a tuple with the value and an estimate of the error, and the other is in how you are vectorizing. You don't want to vectorize on the vectors parameter. np.vectorize has a for loop, so there is no performance gain from doing it yourself:

def func(x, p):
    """ Convolution of gaussian and rectangle is a gaussian integral.
        Parameters: A, mu, sigma, a"""
    A, mu, sigma, a = p
    return quad(lambda t: gaus(x-t,A,mu,sigma),-a,a)[0]

def vfunc(x, *p):
    evaluations = numpy.array([func(i, p) for i in x])
    return evaluations

Note that I have taken the * in func away, but not from gaus. Also, I am selecting the first output of quad.

Whereas this solves your problem, to fit a convolution you may consider going to Fourier space. The Fourier transform of a convolution is the product of the transforms of the functions, and this is going to simplify your life a lot. Furthermore, once in Fourier space you may consider applying a low-pass filter to reduce noise. 210 data points are high enough to get good results.

Also, if you need more powerful algorithms, you should consider iminuit, using ROOT's long proven Minuit.


Related Query