【发布时间】:2012-11-02 13:07:05
【问题描述】:
屏蔽数组的 numpy 多项式拟合函数 ma.polyfit 在整数输入时崩溃:
import numpy.ma as ma
x = ma.arange(2)
y = ma.arange(2)
p1 = ma.polyfit(np.float32(x), y, deg=1)
p2 = ma.polyfit( x , y, deg=1)
最后一行导致错误:
ValueError: data type <type 'numpy.int64'> not inexact
为什么我不能用整数 x 值拟合数据(普通的 numpy.polyfit 函数没有问题),这是一个(已知的)错误吗?
【问题讨论】:
标签: numpy curve-fitting polynomial-math maskedinput