我使用以下代码:
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),然后yEnterprise就一团糟:
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]
yEnterprise的某些值应该在正0.30左右,而不是-28和-29
传递给splrep
的x值范围为80到115。您正在以0到1之间的值评估样条曲线。如果在输入范围内的值进行评估,输出将在0.3左右。