Я пытаюсь интегрировать следующие данные численно:
t,y
9.960000000000001e-05,8.334379999999999e-05
9.98e-05,0.000126125
0.0001,0.00018125
0.0001002,0.0002385
0.00010040000000000001,0.000289625
0.0001006,0.000347313
0.0001008,0.000391719
0.000101,0.00043284399999999994
0.00010120000000000001,0.000472375
0.00010140000000000001,0.000502469
0.00010160000000000002,0.000528594
0.00010180000000000001,0.000546219
0.000102,0.000569188
0.0001022,0.000584719
0.0001024,0.000593969
0.00010260000000000001,0.000607375
0.0001028,0.000618906
0.000103,0.000629344
0.0001032,0.000629344
0.0001034,0.000636313
0.00010360000000000001,0.0006374999999999999
0.0001038,0.000630375
0.00010400000000000001,0.00059875
0.0001042,0.00046825
0.0001044,0.000287344
0.00010460000000000002,0.000208594
0.0001048,0.000196094
0.000105,0.000172625
0.00010520000000000001,0.000134781
0.0001054,0.000115906
0.0001056,0.00010306300000000001
0.00010580000000000001,9.31563e-05
Как показано ниже, я читаю этот набор данных из файла CSV.Это мой код:
import pandas as pd
from scipy.integrate import trapz, simps
root="my/root/dir"
df = pd.read_csv(root+r"simps.csv")
print(trapz(df["t"], df["y"]))
print(simps(df["t"], df["y"]))
trapz возвращает значение (-9.5865055e-10), в то время как Simps возвращает nan и следующую ошибку:
anaconda\path\scipy\integrate\quadrature.py:324: RuntimeWarning: divide by zero encountered in true_divide
h0divh1 = h0 / h1
anaconda\path\scipy\integrate\quadrature.py:326: RuntimeWarning: divide by zero encountered in true_divide
y[slice1]*hsum*hsum/hprod +
anaconda\path\scipy\integrate\quadrature.py:327: RuntimeWarning: invalid value encountered in add
y[slice2]*(2-h0divh1))
anaconda\path\scipy\integrate\quadrature.py:326: RuntimeWarning: invalid value encountered in add
y[slice1]*hsum*hsum/hprod +
Почему возникает эта ошибка?