Note
Go to the end to download the full example code.
Model - with iter callbackΒΆ
ITER -1 ['peak_amplitude = 3.00000', 'peak_center = 6.00000', 'peak_sigma = 2.00000', 'bkg_slope = 0.00000', 'bkg_intercept = 0.00000', 'peak_fwhm = 4.70964', 'peak_height = 0.59841']
ITER 0 ['peak_amplitude = 3.00000', 'peak_center = 6.00000', 'peak_sigma = 2.00000', 'bkg_slope = 0.00000', 'bkg_intercept = 0.00000', 'peak_fwhm = 4.70964', 'peak_height = 0.59841']
ITER 1 ['peak_amplitude = 3.00000', 'peak_center = 6.00000', 'peak_sigma = 2.00000', 'bkg_slope = 0.00000', 'bkg_intercept = 0.00000', 'peak_fwhm = 4.70964', 'peak_height = 0.59841']
ITER 2 ['peak_amplitude = 3.00004', 'peak_center = 6.00000', 'peak_sigma = 2.00000', 'bkg_slope = 0.00000', 'bkg_intercept = 0.00000', 'peak_fwhm = 4.70964', 'peak_height = 0.59842']
ITER 3 ['peak_amplitude = 3.00000', 'peak_center = 6.00004', 'peak_sigma = 2.00000', 'bkg_slope = 0.00000', 'bkg_intercept = 0.00000', 'peak_fwhm = 4.70964', 'peak_height = 0.59841']
ITER 4 ['peak_amplitude = 3.00000', 'peak_center = 6.00000', 'peak_sigma = 2.00003', 'bkg_slope = 0.00000', 'bkg_intercept = 0.00000', 'peak_fwhm = 4.70970', 'peak_height = 0.59841']
ITER 5 ['peak_amplitude = 3.00000', 'peak_center = 6.00000', 'peak_sigma = 2.00000', 'bkg_slope = 0.00001', 'bkg_intercept = 0.00000', 'peak_fwhm = 4.70964', 'peak_height = 0.59841']
ITER 6 ['peak_amplitude = 3.00000', 'peak_center = 6.00000', 'peak_sigma = 2.00000', 'bkg_slope = 0.00000', 'bkg_intercept = 0.00001', 'peak_fwhm = 4.70964', 'peak_height = 0.59841']
ITER 7 ['peak_amplitude = 28.06096', 'peak_center = 19.99268', 'peak_sigma = 6.62280', 'bkg_slope = -0.20866', 'bkg_intercept = 3.28814', 'peak_fwhm = 15.59550', 'peak_height = 1.69033']
ITER 8 ['peak_amplitude = 28.06125', 'peak_center = 19.99268', 'peak_sigma = 6.62280', 'bkg_slope = -0.20866', 'bkg_intercept = 3.28814', 'peak_fwhm = 15.59550', 'peak_height = 1.69034']
ITER 9 ['peak_amplitude = 28.06096', 'peak_center = 19.99267', 'peak_sigma = 6.62280', 'bkg_slope = -0.20866', 'bkg_intercept = 3.28814', 'peak_fwhm = 15.59550', 'peak_height = 1.69033']
ITER 10 ['peak_amplitude = 28.06096', 'peak_center = 19.99268', 'peak_sigma = 6.62288', 'bkg_slope = -0.20866', 'bkg_intercept = 3.28814', 'peak_fwhm = 15.59568', 'peak_height = 1.69031']
ITER 11 ['peak_amplitude = 28.06096', 'peak_center = 19.99268', 'peak_sigma = 6.62280', 'bkg_slope = -0.20866', 'bkg_intercept = 3.28814', 'peak_fwhm = 15.59550', 'peak_height = 1.69033']
ITER 12 ['peak_amplitude = 28.06096', 'peak_center = 19.99268', 'peak_sigma = 6.62280', 'bkg_slope = -0.20866', 'bkg_intercept = 3.28818', 'peak_fwhm = 15.59550', 'peak_height = 1.69033']
ITER 13 ['peak_amplitude = 69.61513', 'peak_center = 11.64712', 'peak_sigma = 18.26748', 'bkg_slope = 0.15397', 'bkg_intercept = 3.00619', 'peak_fwhm = 43.01664', 'peak_height = 1.52032']
ITER 14 ['peak_amplitude = 26.14334', 'peak_center = 19.99783', 'peak_sigma = 17.92626', 'bkg_slope = -0.18990', 'bkg_intercept = 3.74340', 'peak_fwhm = 42.21311', 'peak_height = 0.58181']
ITER 15 ['peak_amplitude = 26.14361', 'peak_center = 19.99783', 'peak_sigma = 17.92626', 'bkg_slope = -0.18990', 'bkg_intercept = 3.74340', 'peak_fwhm = 42.21311', 'peak_height = 0.58182']
ITER 16 ['peak_amplitude = 26.14334', 'peak_center = 19.99783', 'peak_sigma = 17.92626', 'bkg_slope = -0.18990', 'bkg_intercept = 3.74340', 'peak_fwhm = 42.21311', 'peak_height = 0.58181']
ITER 17 ['peak_amplitude = 26.14334', 'peak_center = 19.99783', 'peak_sigma = 17.92644', 'bkg_slope = -0.18990', 'bkg_intercept = 3.74340', 'peak_fwhm = 42.21355', 'peak_height = 0.58180']
ITER 18 ['peak_amplitude = 26.14334', 'peak_center = 19.99783', 'peak_sigma = 17.92626', 'bkg_slope = -0.18989', 'bkg_intercept = 3.74340', 'peak_fwhm = 42.21311', 'peak_height = 0.58181']
ITER 19 ['peak_amplitude = 26.14334', 'peak_center = 19.99783', 'peak_sigma = 17.92626', 'bkg_slope = -0.18990', 'bkg_intercept = 3.74343', 'peak_fwhm = 42.21311', 'peak_height = 0.58181']
ITER 20 ['peak_amplitude = 28.96026', 'peak_center = 19.98918', 'peak_sigma = 18.29596', 'bkg_slope = -0.27575', 'bkg_intercept = 4.75376', 'peak_fwhm = 43.08370', 'peak_height = 0.63148']
ITER 21 ['peak_amplitude = 28.96056', 'peak_center = 19.98918', 'peak_sigma = 18.29596', 'bkg_slope = -0.27575', 'bkg_intercept = 4.75376', 'peak_fwhm = 43.08370', 'peak_height = 0.63148']
ITER 22 ['peak_amplitude = 28.96026', 'peak_center = 19.98917', 'peak_sigma = 18.29596', 'bkg_slope = -0.27575', 'bkg_intercept = 4.75376', 'peak_fwhm = 43.08370', 'peak_height = 0.63148']
ITER 23 ['peak_amplitude = 28.96026', 'peak_center = 19.98918', 'peak_sigma = 18.29616', 'bkg_slope = -0.27575', 'bkg_intercept = 4.75376', 'peak_fwhm = 43.08416', 'peak_height = 0.63147']
ITER 24 ['peak_amplitude = 28.96026', 'peak_center = 19.98918', 'peak_sigma = 18.29596', 'bkg_slope = -0.27574', 'bkg_intercept = 4.75376', 'peak_fwhm = 43.08370', 'peak_height = 0.63148']
ITER 25 ['peak_amplitude = 28.96026', 'peak_center = 19.98918', 'peak_sigma = 18.29596', 'bkg_slope = -0.27575', 'bkg_intercept = 4.75381', 'peak_fwhm = 43.08370', 'peak_height = 0.63148']
ITER 26 ['peak_amplitude = 49.50287', 'peak_center = 18.93364', 'peak_sigma = 0.30541', 'bkg_slope = -0.35174', 'bkg_intercept = 4.83315', 'peak_fwhm = 0.71918', 'peak_height = 64.66412']
ITER 27 ['peak_amplitude = 29.93395', 'peak_center = 19.97768', 'peak_sigma = 17.89130', 'bkg_slope = -0.29348', 'bkg_intercept = 4.93342', 'peak_fwhm = 42.13079', 'peak_height = 0.66747']
ITER 28 ['peak_amplitude = 29.93426', 'peak_center = 19.97768', 'peak_sigma = 17.89130', 'bkg_slope = -0.29348', 'bkg_intercept = 4.93342', 'peak_fwhm = 42.13079', 'peak_height = 0.66748']
ITER 29 ['peak_amplitude = 29.93395', 'peak_center = 19.97767', 'peak_sigma = 17.89130', 'bkg_slope = -0.29348', 'bkg_intercept = 4.93342', 'peak_fwhm = 42.13079', 'peak_height = 0.66747']
ITER 30 ['peak_amplitude = 29.93395', 'peak_center = 19.97768', 'peak_sigma = 17.89149', 'bkg_slope = -0.29348', 'bkg_intercept = 4.93342', 'peak_fwhm = 42.13124', 'peak_height = 0.66746']
ITER 31 ['peak_amplitude = 29.93395', 'peak_center = 19.97768', 'peak_sigma = 17.89130', 'bkg_slope = -0.29347', 'bkg_intercept = 4.93342', 'peak_fwhm = 42.13079', 'peak_height = 0.66747']
ITER 32 ['peak_amplitude = 29.93395', 'peak_center = 19.97768', 'peak_sigma = 17.89130', 'bkg_slope = -0.29348', 'bkg_intercept = 4.93347', 'peak_fwhm = 42.13079', 'peak_height = 0.66747']
ITER 33 ['peak_amplitude = 33.93754', 'peak_center = 19.80974', 'peak_sigma = 14.52919', 'bkg_slope = -0.31329', 'bkg_intercept = 5.00443', 'peak_fwhm = 34.21363', 'peak_height = 0.93186']
ITER 34 ['peak_amplitude = 33.93789', 'peak_center = 19.80974', 'peak_sigma = 14.52919', 'bkg_slope = -0.31329', 'bkg_intercept = 5.00443', 'peak_fwhm = 34.21363', 'peak_height = 0.93187']
ITER 35 ['peak_amplitude = 33.93754', 'peak_center = 19.80971', 'peak_sigma = 14.52919', 'bkg_slope = -0.31329', 'bkg_intercept = 5.00443', 'peak_fwhm = 34.21363', 'peak_height = 0.93186']
ITER 36 ['peak_amplitude = 33.93754', 'peak_center = 19.80974', 'peak_sigma = 14.52935', 'bkg_slope = -0.31329', 'bkg_intercept = 5.00443', 'peak_fwhm = 34.21399', 'peak_height = 0.93185']
ITER 37 ['peak_amplitude = 33.93754', 'peak_center = 19.80974', 'peak_sigma = 14.52919', 'bkg_slope = -0.31328', 'bkg_intercept = 5.00443', 'peak_fwhm = 34.21363', 'peak_height = 0.93186']
ITER 38 ['peak_amplitude = 33.93754', 'peak_center = 19.80974', 'peak_sigma = 14.52919', 'bkg_slope = -0.31329', 'bkg_intercept = 5.00448', 'peak_fwhm = 34.21363', 'peak_height = 0.93186']
ITER 39 ['peak_amplitude = 39.94969', 'peak_center = 11.63266', 'peak_sigma = 17.05427', 'bkg_slope = -0.30912', 'bkg_intercept = 4.82241', 'peak_fwhm = 40.15974', 'peak_height = 0.93452']
ITER 40 ['peak_amplitude = 39.95010', 'peak_center = 11.63266', 'peak_sigma = 17.05427', 'bkg_slope = -0.30912', 'bkg_intercept = 4.82241', 'peak_fwhm = 40.15974', 'peak_height = 0.93453']
ITER 41 ['peak_amplitude = 39.94969', 'peak_center = 11.63237', 'peak_sigma = 17.05427', 'bkg_slope = -0.30912', 'bkg_intercept = 4.82241', 'peak_fwhm = 40.15974', 'peak_height = 0.93452']
ITER 42 ['peak_amplitude = 39.94969', 'peak_center = 11.63266', 'peak_sigma = 17.05445', 'bkg_slope = -0.30912', 'bkg_intercept = 4.82241', 'peak_fwhm = 40.16016', 'peak_height = 0.93451']
ITER 43 ['peak_amplitude = 39.94969', 'peak_center = 11.63266', 'peak_sigma = 17.05427', 'bkg_slope = -0.30911', 'bkg_intercept = 4.82241', 'peak_fwhm = 40.15974', 'peak_height = 0.93452']
ITER 44 ['peak_amplitude = 39.94969', 'peak_center = 11.63266', 'peak_sigma = 17.05427', 'bkg_slope = -0.30912', 'bkg_intercept = 4.82246', 'peak_fwhm = 40.15974', 'peak_height = 0.93452']
ITER 45 ['peak_amplitude = 43.44365', 'peak_center = 7.65269', 'peak_sigma = 0.17915', 'bkg_slope = -0.30320', 'bkg_intercept = 3.85514', 'peak_fwhm = 0.42187', 'peak_height = 96.74097']
ITER 46 ['peak_amplitude = 40.21652', 'peak_center = 11.53095', 'peak_sigma = 15.41291', 'bkg_slope = -0.30665', 'bkg_intercept = 4.70376', 'peak_fwhm = 36.29462', 'peak_height = 1.04095']
ITER 47 ['peak_amplitude = 40.21693', 'peak_center = 11.53095', 'peak_sigma = 15.41291', 'bkg_slope = -0.30665', 'bkg_intercept = 4.70376', 'peak_fwhm = 36.29462', 'peak_height = 1.04096']
ITER 48 ['peak_amplitude = 40.21652', 'peak_center = 11.53065', 'peak_sigma = 15.41291', 'bkg_slope = -0.30665', 'bkg_intercept = 4.70376', 'peak_fwhm = 36.29462', 'peak_height = 1.04095']
ITER 49 ['peak_amplitude = 40.21652', 'peak_center = 11.53095', 'peak_sigma = 15.41307', 'bkg_slope = -0.30665', 'bkg_intercept = 4.70376', 'peak_fwhm = 36.29500', 'peak_height = 1.04094']
ITER 50 ['peak_amplitude = 40.21652', 'peak_center = 11.53095', 'peak_sigma = 15.41291', 'bkg_slope = -0.30665', 'bkg_intercept = 4.70376', 'peak_fwhm = 36.29462', 'peak_height = 1.04095']
ITER 51 ['peak_amplitude = 40.21652', 'peak_center = 11.53095', 'peak_sigma = 15.41291', 'bkg_slope = -0.30665', 'bkg_intercept = 4.70381', 'peak_fwhm = 36.29462', 'peak_height = 1.04095']
ITER 52 ['peak_amplitude = 40.73607', 'peak_center = 10.91338', 'peak_sigma = 11.96371', 'bkg_slope = -0.30679', 'bkg_intercept = 4.50063', 'peak_fwhm = 28.17238', 'peak_height = 1.35839']
ITER 53 ['peak_amplitude = 40.73648', 'peak_center = 10.91338', 'peak_sigma = 11.96371', 'bkg_slope = -0.30679', 'bkg_intercept = 4.50063', 'peak_fwhm = 28.17238', 'peak_height = 1.35840']
ITER 54 ['peak_amplitude = 40.73607', 'peak_center = 10.91308', 'peak_sigma = 11.96371', 'bkg_slope = -0.30679', 'bkg_intercept = 4.50063', 'peak_fwhm = 28.17238', 'peak_height = 1.35839']
ITER 55 ['peak_amplitude = 40.73607', 'peak_center = 10.91338', 'peak_sigma = 11.96384', 'bkg_slope = -0.30679', 'bkg_intercept = 4.50063', 'peak_fwhm = 28.17268', 'peak_height = 1.35837']
ITER 56 ['peak_amplitude = 40.73607', 'peak_center = 10.91338', 'peak_sigma = 11.96371', 'bkg_slope = -0.30679', 'bkg_intercept = 4.50063', 'peak_fwhm = 28.17238', 'peak_height = 1.35839']
ITER 57 ['peak_amplitude = 40.73607', 'peak_center = 10.91338', 'peak_sigma = 11.96371', 'bkg_slope = -0.30679', 'bkg_intercept = 4.50068', 'peak_fwhm = 28.17238', 'peak_height = 1.35839']
ITER 58 ['peak_amplitude = 40.86269', 'peak_center = 9.92047', 'peak_sigma = 5.29355', 'bkg_slope = -0.31543', 'bkg_intercept = 4.04328', 'peak_fwhm = 12.46536', 'peak_height = 3.07957']
ITER 59 ['peak_amplitude = 40.86311', 'peak_center = 9.92047', 'peak_sigma = 5.29355', 'bkg_slope = -0.31543', 'bkg_intercept = 4.04328', 'peak_fwhm = 12.46536', 'peak_height = 3.07960']
ITER 60 ['peak_amplitude = 40.86269', 'peak_center = 9.92015', 'peak_sigma = 5.29355', 'bkg_slope = -0.31543', 'bkg_intercept = 4.04328', 'peak_fwhm = 12.46536', 'peak_height = 3.07957']
ITER 61 ['peak_amplitude = 40.86269', 'peak_center = 9.92047', 'peak_sigma = 5.29361', 'bkg_slope = -0.31543', 'bkg_intercept = 4.04328', 'peak_fwhm = 12.46550', 'peak_height = 3.07953']
ITER 62 ['peak_amplitude = 40.86269', 'peak_center = 9.92047', 'peak_sigma = 5.29355', 'bkg_slope = -0.31542', 'bkg_intercept = 4.04328', 'peak_fwhm = 12.46536', 'peak_height = 3.07957']
ITER 63 ['peak_amplitude = 40.86269', 'peak_center = 9.92047', 'peak_sigma = 5.29355', 'bkg_slope = -0.31543', 'bkg_intercept = 4.04332', 'peak_fwhm = 12.46536', 'peak_height = 3.07957']
ITER 64 ['peak_amplitude = 34.49433', 'peak_center = 6.96011', 'peak_sigma = 3.79883', 'bkg_slope = -0.21584', 'bkg_intercept = 3.04624', 'peak_fwhm = 8.94557', 'peak_height = 3.62249']
ITER 65 ['peak_amplitude = 34.49469', 'peak_center = 6.96011', 'peak_sigma = 3.79883', 'bkg_slope = -0.21584', 'bkg_intercept = 3.04624', 'peak_fwhm = 8.94557', 'peak_height = 3.62253']
ITER 66 ['peak_amplitude = 34.49433', 'peak_center = 6.95978', 'peak_sigma = 3.79883', 'bkg_slope = -0.21584', 'bkg_intercept = 3.04624', 'peak_fwhm = 8.94557', 'peak_height = 3.62249']
ITER 67 ['peak_amplitude = 34.49433', 'peak_center = 6.96011', 'peak_sigma = 3.79888', 'bkg_slope = -0.21584', 'bkg_intercept = 3.04624', 'peak_fwhm = 8.94568', 'peak_height = 3.62245']
ITER 68 ['peak_amplitude = 34.49433', 'peak_center = 6.96011', 'peak_sigma = 3.79883', 'bkg_slope = -0.21584', 'bkg_intercept = 3.04624', 'peak_fwhm = 8.94557', 'peak_height = 3.62249']
ITER 69 ['peak_amplitude = 34.49433', 'peak_center = 6.96011', 'peak_sigma = 3.79883', 'bkg_slope = -0.21584', 'bkg_intercept = 3.04628', 'peak_fwhm = 8.94557', 'peak_height = 3.62249']
ITER 70 ['peak_amplitude = 0.08766', 'peak_center = 8.87255', 'peak_sigma = 0.10402', 'bkg_slope = -0.26833', 'bkg_intercept = 4.93654', 'peak_fwhm = 0.24494', 'peak_height = 0.33620']
ITER 71 ['peak_amplitude = 30.67432', 'peak_center = 8.04096', 'peak_sigma = 1.99254', 'bkg_slope = -0.19527', 'bkg_intercept = 2.91723', 'peak_fwhm = 4.69208', 'peak_height = 6.14155']
ITER 72 ['peak_amplitude = 30.67464', 'peak_center = 8.04096', 'peak_sigma = 1.99254', 'bkg_slope = -0.19527', 'bkg_intercept = 2.91723', 'peak_fwhm = 4.69208', 'peak_height = 6.14161']
ITER 73 ['peak_amplitude = 30.67432', 'peak_center = 8.04063', 'peak_sigma = 1.99254', 'bkg_slope = -0.19527', 'bkg_intercept = 2.91723', 'peak_fwhm = 4.69208', 'peak_height = 6.14155']
ITER 74 ['peak_amplitude = 30.67432', 'peak_center = 8.04096', 'peak_sigma = 1.99257', 'bkg_slope = -0.19527', 'bkg_intercept = 2.91723', 'peak_fwhm = 4.69214', 'peak_height = 6.14147']
ITER 75 ['peak_amplitude = 30.67432', 'peak_center = 8.04096', 'peak_sigma = 1.99254', 'bkg_slope = -0.19527', 'bkg_intercept = 2.91723', 'peak_fwhm = 4.69208', 'peak_height = 6.14155']
ITER 76 ['peak_amplitude = 30.67432', 'peak_center = 8.04096', 'peak_sigma = 1.99254', 'bkg_slope = -0.19527', 'bkg_intercept = 2.91726', 'peak_fwhm = 4.69208', 'peak_height = 6.14155']
ITER 77 ['peak_amplitude = 21.89977', 'peak_center = 7.48302', 'peak_sigma = 1.18769', 'bkg_slope = -0.19932', 'bkg_intercept = 3.46743', 'peak_fwhm = 2.79680', 'peak_height = 7.35606']
ITER 78 ['peak_amplitude = 21.90000', 'peak_center = 7.48302', 'peak_sigma = 1.18769', 'bkg_slope = -0.19932', 'bkg_intercept = 3.46743', 'peak_fwhm = 2.79680', 'peak_height = 7.35614']
ITER 79 ['peak_amplitude = 21.89977', 'peak_center = 7.48269', 'peak_sigma = 1.18769', 'bkg_slope = -0.19932', 'bkg_intercept = 3.46743', 'peak_fwhm = 2.79680', 'peak_height = 7.35606']
ITER 80 ['peak_amplitude = 21.89977', 'peak_center = 7.48302', 'peak_sigma = 1.18771', 'bkg_slope = -0.19932', 'bkg_intercept = 3.46743', 'peak_fwhm = 2.79684', 'peak_height = 7.35595']
ITER 81 ['peak_amplitude = 21.89977', 'peak_center = 7.48302', 'peak_sigma = 1.18769', 'bkg_slope = -0.19932', 'bkg_intercept = 3.46743', 'peak_fwhm = 2.79680', 'peak_height = 7.35606']
ITER 82 ['peak_amplitude = 21.89977', 'peak_center = 7.48302', 'peak_sigma = 1.18769', 'bkg_slope = -0.19932', 'bkg_intercept = 3.46746', 'peak_fwhm = 2.79680', 'peak_height = 7.35606']
ITER 83 ['peak_amplitude = 24.51986', 'peak_center = 7.64789', 'peak_sigma = 1.23846', 'bkg_slope = -0.20238', 'bkg_intercept = 3.36745', 'peak_fwhm = 2.91635', 'peak_height = 7.89852']
ITER 84 ['peak_amplitude = 24.52011', 'peak_center = 7.64789', 'peak_sigma = 1.23846', 'bkg_slope = -0.20238', 'bkg_intercept = 3.36745', 'peak_fwhm = 2.91635', 'peak_height = 7.89861']
ITER 85 ['peak_amplitude = 24.51986', 'peak_center = 7.64756', 'peak_sigma = 1.23846', 'bkg_slope = -0.20238', 'bkg_intercept = 3.36745', 'peak_fwhm = 2.91635', 'peak_height = 7.89852']
ITER 86 ['peak_amplitude = 24.51986', 'peak_center = 7.64789', 'peak_sigma = 1.23848', 'bkg_slope = -0.20238', 'bkg_intercept = 3.36745', 'peak_fwhm = 2.91639', 'peak_height = 7.89841']
ITER 87 ['peak_amplitude = 24.51986', 'peak_center = 7.64789', 'peak_sigma = 1.23846', 'bkg_slope = -0.20238', 'bkg_intercept = 3.36745', 'peak_fwhm = 2.91635', 'peak_height = 7.89852']
ITER 88 ['peak_amplitude = 24.51986', 'peak_center = 7.64789', 'peak_sigma = 1.23846', 'bkg_slope = -0.20238', 'bkg_intercept = 3.36748', 'peak_fwhm = 2.91635', 'peak_height = 7.89852']
ITER 89 ['peak_amplitude = 24.52133', 'peak_center = 7.63730', 'peak_sigma = 1.22397', 'bkg_slope = -0.20264', 'bkg_intercept = 3.36998', 'peak_fwhm = 2.88223', 'peak_height = 7.99252']
ITER 90 ['peak_amplitude = 24.52158', 'peak_center = 7.63730', 'peak_sigma = 1.22397', 'bkg_slope = -0.20264', 'bkg_intercept = 3.36998', 'peak_fwhm = 2.88223', 'peak_height = 7.99260']
ITER 91 ['peak_amplitude = 24.52133', 'peak_center = 7.63697', 'peak_sigma = 1.22397', 'bkg_slope = -0.20264', 'bkg_intercept = 3.36998', 'peak_fwhm = 2.88223', 'peak_height = 7.99252']
ITER 92 ['peak_amplitude = 24.52133', 'peak_center = 7.63730', 'peak_sigma = 1.22399', 'bkg_slope = -0.20264', 'bkg_intercept = 3.36998', 'peak_fwhm = 2.88227', 'peak_height = 7.99240']
ITER 93 ['peak_amplitude = 24.52133', 'peak_center = 7.63730', 'peak_sigma = 1.22397', 'bkg_slope = -0.20264', 'bkg_intercept = 3.36998', 'peak_fwhm = 2.88223', 'peak_height = 7.99252']
ITER 94 ['peak_amplitude = 24.52133', 'peak_center = 7.63730', 'peak_sigma = 1.22397', 'bkg_slope = -0.20264', 'bkg_intercept = 3.37001', 'peak_fwhm = 2.88223', 'peak_height = 7.99252']
ITER 95 ['peak_amplitude = 24.52372', 'peak_center = 7.63753', 'peak_sigma = 1.22415', 'bkg_slope = -0.20264', 'bkg_intercept = 3.36986', 'peak_fwhm = 2.88265', 'peak_height = 7.99214']
ITER 96 ['peak_amplitude = 24.52397', 'peak_center = 7.63753', 'peak_sigma = 1.22415', 'bkg_slope = -0.20264', 'bkg_intercept = 3.36986', 'peak_fwhm = 2.88265', 'peak_height = 7.99222']
ITER 97 ['peak_amplitude = 24.52372', 'peak_center = 7.63720', 'peak_sigma = 1.22415', 'bkg_slope = -0.20264', 'bkg_intercept = 3.36986', 'peak_fwhm = 2.88265', 'peak_height = 7.99214']
ITER 98 ['peak_amplitude = 24.52372', 'peak_center = 7.63753', 'peak_sigma = 1.22416', 'bkg_slope = -0.20264', 'bkg_intercept = 3.36986', 'peak_fwhm = 2.88269', 'peak_height = 7.99202']
ITER 99 ['peak_amplitude = 24.52372', 'peak_center = 7.63753', 'peak_sigma = 1.22415', 'bkg_slope = -0.20264', 'bkg_intercept = 3.36986', 'peak_fwhm = 2.88265', 'peak_height = 7.99214']
ITER 100 ['peak_amplitude = 24.52372', 'peak_center = 7.63753', 'peak_sigma = 1.22415', 'bkg_slope = -0.20264', 'bkg_intercept = 3.36989', 'peak_fwhm = 2.88265', 'peak_height = 7.99214']
ITER 101 ['peak_amplitude = 24.52371', 'peak_center = 7.63753', 'peak_sigma = 1.22415', 'bkg_slope = -0.20264', 'bkg_intercept = 3.36986', 'peak_fwhm = 2.88264', 'peak_height = 7.99214']
ITER 101 ['peak_amplitude = 24.52371', 'peak_center = 7.63753', 'peak_sigma = 1.22415', 'bkg_slope = -0.20264', 'bkg_intercept = 3.36986', 'peak_fwhm = 2.88264', 'peak_height = 7.99214']
Nfev = 101
[[Model]]
(Model(gaussian, prefix='peak_') + Model(linear, prefix='bkg_'))
[[Fit Statistics]]
# fitting method = leastsq
# function evals = 101
# data points = 401
# variables = 5
chi-square = 20.0043556
reduced chi-square = 0.05051605
Akaike info crit = -1192.20257
Bayesian info crit = -1172.23276
R-squared = 0.99377421
[[Variables]]
peak_amplitude: 24.5237052 +/- 0.16281835 (0.66%) (init = 3)
peak_center: 7.63752785 +/- 0.00746969 (0.10%) (init = 6)
peak_sigma: 1.22414559 +/- 0.00811005 (0.66%) (init = 2)
bkg_slope: -0.20264093 +/- 0.00204346 (1.01%) (init = 0)
bkg_intercept: 3.36986054 +/- 0.02653942 (0.79%) (init = 0)
peak_fwhm: 2.88264251 +/- 0.01909771 (0.66%) == '2.3548200*peak_sigma'
peak_height: 7.99214038 +/- 0.04318559 (0.54%) == '0.3989423*peak_amplitude/max(1e-15, peak_sigma)'
[[Correlations]] (unreported correlations are < 0.100)
C(bkg_slope, bkg_intercept) = -0.8574
C(peak_amplitude, peak_sigma) = +0.6681
C(peak_amplitude, bkg_intercept) = -0.5260
C(peak_sigma, bkg_intercept) = -0.3514
C(peak_amplitude, bkg_slope) = +0.2858
C(peak_sigma, bkg_slope) = +0.1909
C(peak_center, bkg_slope) = -0.1451
C(peak_center, bkg_intercept) = +0.1244
# <examples/doc_with_itercb.py>
import matplotlib.pyplot as plt
from numpy import linspace, random
from lmfit.lineshapes import gaussian
from lmfit.models import GaussianModel, LinearModel
def per_iteration(pars, iteration, resid, *args, **kws):
print(" ITER ", iteration, [f"{p.name} = {p.value:.5f}" for p in pars.values()])
x = linspace(0., 20, 401)
y = gaussian(x, amplitude=24.56, center=7.6543, sigma=1.23)
random.seed(2021)
y = y - .20*x + 3.333 + random.normal(scale=0.23, size=x.size)
mod = GaussianModel(prefix='peak_') + LinearModel(prefix='bkg_')
pars = mod.make_params(peak_amplitude=dict(value=3.0, min=0),
peak_center=dict(value=6.0, min=0, max=20),
peak_sigma=2.0,
bkg_intercept=0,
bkg_slope=0)
out = mod.fit(y, pars, x=x, iter_cb=per_iteration)
plt.plot(x, y, '--')
print(f'Nfev = {out.nfev}')
print(out.fit_report())
plt.plot(x, out.best_fit, '-', label='best fit')
plt.legend()
plt.show()
# <end examples/doc_with_itercb.py>
Total running time of the script: (0 minutes 0.212 seconds)