[Python] How to fit with scipy.optimize.curve_fit when numbers are not close to 1?

Discussão em 'Python' iniciado por Stack, Maio 27, 2025.

  1. Stack

    Stack Membro Participativo

    I have a set of x,y points in which x lies between 0 and 100e-12 while y ranges between 0 and 1e9 and want to use scipy.optimize.curve_fit to fit a model. It fails because of the numbers. If I rescale the data so that the numbers are closer to 1 (i.e. x*=1e10 and y*=1e-9), then it works. So I know where the problem is and could eventually live with this solution. But would prefer to perform the fit in the original scale.

    Is it possible?

    I have seen an answer where it is suggested to use a diag argument but with this I get: least_squares() got an unexpected keyword argument 'diag'. I guess it was from an older version. Is there an analogous for the current version?

    Additional info: I am providing curve_fit with very reasonable p0.

    Continue reading...

Compartilhe esta Página