scipy.optimize.curvefit() - array must not contain infs or NaNs

后端 未结 3 1498
孤城傲影
孤城傲影 2021-02-05 15:34

I am trying to fit some data to a curve in Python using scipy.optimize.curve_fit. I am running into the error ValueError: array must not contain infs or NaNs.

3条回答
  •  囚心锁ツ
    2021-02-05 16:20

    Your function has a negative power (x^-alpha) this is the same as (1/x)^(alpha). If x is ever 0 your function will return inf and your curve fit operation will break, I'm surprised a warning/error isn't thrown earlier informing you of a divide by 0.

    BTW why are you multiplying and dividing by 1?

提交回复
热议问题