from scipy.optimize import curve_fit
import matplotlib.pyplot as plt
import numpy as np
import pylandau

x = np.arange(0, 100, 0.5)
mpv, eta, sigma, A = 10, 1, 3, 1
y = pylandau.langau(x, mpv, eta, sigma, A) + np.random.normal(0, 0.05, 200)

coeff, pcov = curve_fit(pylandau.langau, x, y, p0=(mpv, eta, sigma, A))
plt.plot(x, y, "o")
plt.plot(x, pylandau.langau(x, *coeff), "-")
plt.show()

@@ -1,8 +1,153 @@
+''' Simple fit without fit error estimation.%0AFor correct fit errors check the advanced example.%0ABound should be defined. Eta has to be %3E 1.%0A'''%0A%0A
 from sci
@@ -247,34 +247,45 @@
 au%0A%0A
-x = np.arange(0, 100, 0.5)
+# Create fake data with possion error
 %0Ampv
@@ -306,19 +306,49 @@
 A = 
-10, 1, 3, 1
+30, 5, 4, 1000%0Ax = np.arange(0, 100, 0.5)
 %0Ay =
@@ -390,10 +390,15 @@
 , A)
- +
+%0Ayerr =
  np.
@@ -415,112 +415,377 @@
 mal(
-0, 0.05, 200)%0A%0Acoeff, pcov = curve_fit(pylandau.langau, x, y, p0=(mpv, eta, sigma, A))%0Aplt.plot(x, y, %22o
+np.zeros_like(x), np.sqrt(y))%0Ayerr%5By %3C 1%5D = 1%0Ay += yerr%0A%0A# Fit with constrains%0Acoeff, pcov = curve_fit(pylandau.langau, x, y,%0A                        sigma=yerr,%0A                        absolute_sigma=True,%0A                        p0=(mpv, eta, sigma, A),%0A                        bounds=(1, 10000))%0A%0A# Plot%0Aplt.errorbar(x, y, np.sqrt(pylandau.langau(x, *coeff)), fmt=%22.
 %22)%0Ap

use scipy fit correctly (errors, start parameter, limits added)