[Python] Gauss Fitting data with scipy and getting strange answers on Fit Quality

Discussão em 'Python' iniciado por Stack, Março 15, 2025.

  1. Stack

    Stack Membro Participativo

    I have Gamma-Spectra and I am doing Gauss fit to the peaks using Python with scipy. Works well, but trying to get a number on fit quality (for the intent on some automation) returns very odd numbers.

    The scipy command is:

    response = scipy.optimize.curve_fit(gauss, e, c, param0, full_output=True, absolute_sigma=True, method=FitMethod, bounds=bounds)


    I get the fit quality from:

    fitQuality = np.linalg.cond(response[1]) # PCOV is response[1]


    FitQuality is a value from zero (excellent fit) up to infinity (beyond lousy). As an example, here is a fit (shaded green) to the K-40 Gamma line in a CsI detector. [​IMG]

    Given the jittery nature of the data, I am pleased with the result. And so is scipy, giving it a FitQuality rating of 18.

    Next picture shows a fit (shaded red) to a Na-22 line in a High-Resolution Ge detector.

    [​IMG]

    Again, I am very pleased with the result. But scipy is giving it a FitQuality rating of 56,982,136; this means very, very poor.

    This does not make sense. The fit is nearly perfect!

    Is my FitQuality formula inappropriate? Does it need additions? Am I completely off the mark? Please, help.

    Continue reading...

Compartilhe esta Página