- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
当我使用scipy.interpolate.splev()
时,我收到一个迄今为止无法解读的错误。 Scipy 版本 1.0.0 和 Python 版本 2.7.6。以下代码重现了它:
from scipy.interpolate import splrep
x = [2107.19568388, 2107.2161156, 2107.23654721, 2107.25697893, 2107.27741044, 2107.74733769, 2107.76776941, 2107.97208545, 2107.99251717, 2108.01294878, 2108.23769664, 2108.25812816, 2108.4624444, 2108.48287591, 2108.50330763, 2108.68719226, 2108.70762377, 2108.72805548, 2108.7484871, 2108.91194001, 2108.93237163, 2108.95280334, 2108.97323485, 2108.99366647, 2109.11625625, 2109.13668777, 2109.15711938, 2109.17755109, 2109.19798261, 2109.93352091, 2109.95395253, 2109.97438424, 2110.15826877, 2110.17870038, 2110.199132, 2110.21956361, 2110.44431147, 2110.46474308, 2110.64862761, 2110.66905923, 2110.68949094, 2110.70992246, 2110.73035407, 2111.09812333, 2111.11855485]
y = [0.608444254293961, 1.1307864656802968, 1.019736639592334, 0.9961412276026707, 0.9592896281866948, 1.2359383661202434, 1.2812703028911483, 0.505895841200648, 0.9512935629735984, 0.9356096606272141, 0.7855456056935104, 0.981954692622873, 1.072663326334132, 1.0593408940891165, 1.1233664656408031, 0.9644455920846516, 0.9314054842890923, 1.0304404875717894, 1.0352072048542664, 1.0450795581773475, 0.872728098339811, 0.9457681125627769, 1.0171913808928397, 0.8019547307735675, 1.0618760993725407, 1.187125996959775, 1.118741742900147, 0.8138502901656298, 0.8938206893668276, 1.1992722199884276, 0.9804337917647384, 1.2044798450916494, 0.37487515771487456, 1.1281341765413573, 1.0916269656818134, 1.0815338524707898, 0.7864996838381028, 1.084513017667964, 0.9275967249553375, 0.9147866697835813, 0.8990815864549077, 0.9901485904924978, 1.0, 1.094349087797393, 1.0823604234628468]
b = [2107.07820195, 2109.10604032, 2111.13387869]
_ = splrep(x,y,t=b)
当我运行此程序时,出现以下错误:
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/nfs/phs3/ar0/S/PROJ/jwallace/venv/lib/python2.7/site-packages/scipy/interpolate/fitpack.py", line 289, in splrep
res = _impl.splrep(x, y, w, xb, xe, k, task, s, t, full_output, per, quiet)
File "/nfs/phs3/ar0/S/PROJ/jwallace/venv/lib/python2.7/site-packages/scipy/interpolate/_fitpack_impl.py", line 514, in splrep
raise _iermess[ier][1](_iermess[ier][0])
ValueError: Error on input data
这个错误
The answer to this question, with the same problem, 是为了确保 x
按升序排列。这是为了我,所以这不是问题。
This bug report's resolution 似乎需要在每个断点之间有 x
的值。我的 x
和 b
组合满足了这一点。
我的数据有什么问题?
最佳答案
每pv's comment in the bug report :
FITPACK requires the knots satisfy the conditions
xb<t(k+2)<t(k+3)<...<t(n-k-1)<xe
the schoenberg-whitney conditions, i.e. there must be a subset of data points xx(j) such that
t(j) < xx(j) < t(j+k+1), j=1,2,...,n-k-1
因此,t
值必须介于 xb
和 xe
之间,即 x
的开始值和结束值.
由于 min(b)
和 max(b)
超出范围 [xb, xe]
,因此引发错误:
In [102]: min(b) < np.array(x).min()
Out[102]: True
In [103]: max(b) > np.array(x).max()
Out[103]: True
此条件已 added to splrep
's docstring从 scipy 版本 0.15.0 开始。
关于python - scipy.interpolate.splev() 错误,不明白来源,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48527473/
我在使用 cx_freeze 和 scipy 时无法编译 exe。特别是,我的脚本使用 from scipy.interpolate import griddata 构建过程似乎成功完成,但是当我尝试
是否可以通过函数在 scipy 中定义一个稀疏矩阵,而不是列出所有可能的值?在文档中,我看到可以通过以下方式创建稀疏矩阵 There are seven available sparse matrix
SciPy为非线性最小二乘问题提供了两种功能: optimize.leastsq()仅使用Levenberg-Marquardt算法。 optimize.least_squares()允许我们选择Le
SciPy 中的求解器能否处理复数值(即 x=x'+i*x")?我对使用 Nelder-Mead 类型的最小化函数特别感兴趣。我通常是 Matlab 用户,我知道 Matlab 没有复杂的求解器。如果
我有看起来像这样的数据集: position number_of_tag_at_this_position 3 4 8 6 13 25 23 12 我想对这个数据集应用三次样条插值来插值标签密度;为此
所以,我正在处理维基百科转储,以计算大约 5,700,000 个页面的页面排名。这些文件经过预处理,因此不是 XML 格式。 它们取自 http://haselgrove.id.au/wikipedi
Scipy 和 Numpy 返回归一化的特征向量。我正在尝试将这些向量用于物理应用程序,我需要它们不被标准化。 例如a = np.matrix('-3, 2; -1, 0') W,V = spl.ei
基于此处提供的解释 1 ,我正在尝试使用相同的想法来加速以下积分: import scipy.integrate as si from scipy.optimize import root, fsol
这很容易重新创建。 如果我的脚本 foo.py 是: import scipy 然后运行: python pyinstaller.py --onefile foo.py 当我启动 foo.exe 时,
我想在我的代码中使用 scipy.spatial.distance.cosine。如果我执行类似 import scipy.spatial 或 from scipy import spatial 的操
Numpy 有一个基本的 pxd,声明它的 c 接口(interface)到 cython。是否有用于 scipy 组件(尤其是 scipy.integrate.quadpack)的 pxd? 或者,
有人可以帮我处理 scipy.stats.chisquare 吗?我没有统计/数学背景,我正在使用来自 https://en.wikipedia.org/wiki/Chi-squared_test 的
我正在使用 scipy.odr 拟合数据与权重,但我不知道如何获得拟合优度或 R 平方的度量。有没有人对如何使用函数存储的输出获得此度量有建议? 最佳答案 res_var Output 的属性是所谓的
我刚刚下载了新的 python 3.8,我正在尝试使用以下方法安装 scipy 包: pip3.8 install scipy 但是构建失败并出现以下错误: **Failed to build sci
我有 my own triangulation algorithm它基于 Delaunay 条件和梯度创建三角剖分,使三角形与梯度对齐。 这是一个示例输出: 以上描述与问题无关,但对于上下文是必要的。
这是一个非常基本的问题,但我似乎找不到好的答案。 scipy 到底计算什么内容 scipy.stats.norm(50,10).pdf(45) 据我了解,平均值为 50、标准差为 10 的高斯中像 4
我正在使用 curve_fit 来拟合一阶动态系统的阶跃响应,以估计增益和时间常数。我使用两种方法。第一种方法是在时域中拟合从函数生成的曲线。 # define the first order dyn
让我们假设 x ~ Poisson(2.5);我想计算类似 E(x | x > 2) 的东西。 我认为这可以通过 .dist.expect 运算符来完成,即: D = stats.poisson(2.
我正在通过 OpenMDAO 使用 SLSQP 来解决优化问题。优化工作充分;最后的 SLSQP 输出如下: Optimization terminated successfully. (Exi
log( VA ) = gamma - (1/eta)log[alpha L ^(-eta) + 测试版 K ^(-eta)] 我试图用非线性最小二乘法估计上述函数。我为此使用了 3 个不同的包(Sc
我是一名优秀的程序员,十分优秀!