我正在使用以下代码:
x = [80, 85, 90, 95, 100, 105, 110, 115]
y = [0.31976258043267208, 0.31718670335264199, 0.30116311412953689, 0.29687766899837931, 0.29802720516866577, 0.30707962224836099, 0.32328422706655086, 0.34467623793716823]
bSpline = scipy.interpolate.splrep(x, y, k=3)
yInterp = scipy.interpolate.splev(np.linspace(0,1,num=8), bSpline)
但是bSpline有奇怪的结(有些是0)然后yInterp都搞砸了:
bSpline: (array([ 80, 80, 80, 80, 90, 95, 100, 105, 115, 115, 115, 115 ]), array([ 0.31976258, 0.33015199, 0.29797999, 0.29680536, 0.29635823,
0.30911387, 0.32907255, 0.34467624, 0, 0, 0, 0 ]), 3)
yInterp: [-29.46356522 -29.3160613 -29.16904367 -29.02251153 -28.87646408, -28.73090053 -28.58582008 -28.44122191]
yInterp应该有一些正值为0.30而不是-28和-29
的值答案 0 :(得分:2)
传递给splrep
的x值范围为80到115.您正在评估样条曲线,其值范围为0到1.如果评估输入范围内的值,则输出将为0.3左右