Roses Boy 2019-09-17 11:44 采纳率: 0%
浏览 213

将Java改成Python中插值问题怎么解决?

Java代码为
PolynomialSplineFunction estimateFunc = lit.interpolate(sx, sy);
double[] x = new double[num_cy];
for (int i = 0; i < num_cy; i++) {
x[i] = Math.round(buchang) / (double)(num_cy+1) * i;
if(x[i]>=Math.round(buchang)-1)
x[i]=Math.round(buchang)-2;
GLSJ144[i] = estimateFunc.value(x[i]);

            if (estimateFunc.isValidPoint(x[i])) {
                GLSJ144[i] = estimateFunc.value(x[i]);
            } else {
                GLSJ144[i] = 0.0;
            }
        }

python改成这样不对为什么?
estimateFunc = interp1d(sx, sy,kind='linear')
x=list(range(self.num_cy))
for i in range(0, self.num_cy):
x[i] = round(buchang)/(self.num_cy+1) * i
if x[i]>=round(buchang)-1:
x[i]=round(buchang)-2
GLSJ144[i] = estimateFunc(x[i])
print((x[i]))
if estimateFunc(x[i]):
GLSJ144[i] = estimateFunc(x[i])
else:
GLSJ144[i] = 0.0
测试发现两个代码的estimateFunc(x[i])值不一样。求大佬帮忙!

  • 写回答

1条回答 默认 最新

  • threenewbee 2019-09-17 13:13
    关注
    评论

报告相同问题?

悬赏问题

  • ¥20 有关区间dp的问题求解
  • ¥15 多电路系统共用电源的串扰问题
  • ¥15 slam rangenet++配置
  • ¥15 有没有研究水声通信方面的帮我改俩matlab代码
  • ¥15 对于相关问题的求解与代码
  • ¥15 ubuntu子系统密码忘记
  • ¥15 信号傅里叶变换在matlab上遇到的小问题请求帮助
  • ¥15 保护模式-系统加载-段寄存器
  • ¥15 电脑桌面设定一个区域禁止鼠标操作
  • ¥15 求NPF226060磁芯的详细资料