y = ar([0, 1, 2, 3, 4, 5, 4, 3, 2, 1])
n = len(x)
mean = sum(x * y) / n
sigma = sum(y * (x - mean) ** 2) / n

def gaus(x, a, x0, sigma):
    return a * exp(-(x - x0) ** 2 / (2 * sigma ** 2))
popt, pcov = curve_fit(gaus, x, y, p0=[1, mean, sigma])
plt.plot(x, y, 'b+:', label='data')
plt.plot(x, gaus(x, *popt), 'ro:', label='fit')
plt.legend()
plt.title('Fig. 3 - Fit for Time Constant')
plt.xlabel('Time (s)')
plt.ylabel('Voltage (V)')
plt.show()
Gaussian fit for Python