- android - 多次调用 OnPrimaryClipChangedListener
- android - 无法更新 RecyclerView 中的 TextView 字段
- android.database.CursorIndexOutOfBoundsException : Index 0 requested, 光标大小为 0
- android - 使用 AppCompat 时,我们是否需要明确指定其 UI 组件(Spinner、EditText)颜色
所以我正在为我的数值类(class)编写一个Python程序,并且我必须编写一个三次样条程序。所以我实现了像Numerical methods by Chapra and canale这样的书中给出的三次样条公式和 Numerical mathematics by chenny and kincaid .
所以我的数据是
x=[1.0,3.0,4.0,7.0]
y=[1.5,4.5,9.0,25.5]
使用此数据并应用三次样条得到 x=1.5
、 y=1.79122340426
虽然使用相同的数据但使用 scipy 函数给出:
>>> scipy.interpolate.interp1d(x, y, kind='cubic')(1.5)
array(1.265624999999932)
那么,为什么结果会有这样的差异呢?很明显,他们没有使用相同的公式。scipy 函数中使用的三次样条公式是什么?它是自然三次样条公式还是改进的公式?注意:值 1.2656 更准确。
最佳答案
编辑:@ev-br 在此答案的评论中对我的答案进行了重要更正。事实上 interp1D 样条线不是基于 FITPACK 的。检查@ev-br 提供的链接的评论。
用于曲线拟合的 Scipy 函数基于 FITPACK。尝试查看有关您正在使用的功能的文档,您将能够看到“引用”章节,其中会出现类似以下内容:
Notes
-----
See splev for evaluation of the spline and its derivatives. Uses the
FORTRAN routine curfit from FITPACK.
If provided, knots `t` must satisfy the Schoenberg-Whitney conditions,
i.e., there must be a subset of data points ``x[j]`` such that
``t[j] < x[j] < t[j+k+1]``, for ``j=0, 1,...,n-k-2``.
References
----------
Based on algorithms described in [1]_, [2]_, [3]_, and [4]_:
.. [1] P. Dierckx, "An algorithm for smoothing, differentiation and
integration of experimental data using spline functions",
J.Comp.Appl.Maths 1 (1975) 165-184.
.. [2] P. Dierckx, "A fast algorithm for smoothing data on a rectangular
grid while using spline functions", SIAM J.Numer.Anal. 19 (1982)
1286-1304.
.. [3] P. Dierckx, "An improved algorithm for curve fitting with spline
functions", report tw54, Dept. Computer Science,K.U. Leuven, 1981.
.. [4] P. Dierckx, "Curve and surface fitting with splines", Monographs on
Numerical Analysis, Oxford University Press, 1993.
这些引用文献尤其取自 fitpack.py 的来源关于函数“splrep”。如果您需要在您的算法和 interp1D 的样条曲线之间进行非常彻底的比较,请访问文档:
您会看到一个名为 [source] 的链接就在函数名称定义之后(例如:scipy.interpolate.interp1D [来源])。请记住,这些函数有很多例程处理程序,因此在浏览源代码时要有耐心。
关于python - scipy.interpolate 中的 interp1d 函数使用什么算法,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36088340/
我正在尝试使用 AngularJS 将 YouTube 视频插入到我的网站中,但我一直收到相同的错误: Error: $interpolate:interr Interpolation Error 为
我正在尝试将动态链接从 json 加载到我的 iframe 模板中。当我加载 iframe 页面时,会弹出此错误。我真的不知道为什么。这是我第一次看到这个错误。下面是代码。 Controller ap
我想从 x 进行插值到 z .但有一个警告: 取决于状态y , 我有一个不同的 xGrid - 我需要对其进行插值。 我有一个 y 的网格, yGrid .说 yGrid=[0,1] .和 xGrid
我是 javascript 的新手,但几周前刚刚钻研 d3.js 尝试创建时空可视化。 我想要实现的是基于以下代码的类似 ( https://jsfiddle.net/dmatekenya/mz5fx
scipy.interpolate.splrep(x, y, w=None, xb=None, xe=None, k=3, task=0, s=None, t=None, full_output=0,
Scipy 函数 griddata和 Rbf两者都可以用于对随机分散的 n 维数据进行插值。它们之间有什么区别?其中之一在准确性或性能方面更胜一筹吗? IMO,这不是 this question 的重
我需要(以数字方式)计算函数的一阶和二阶导数,为此我尝试同时使用 splrep 和 UnivariateSpline 来创建样条曲线插值函数的导数。 但是,对于幅度为 10^-1 或更低的函数,样条表
好的,所以我最近一直在研究插值。遗憾的是,我读过的几乎每篇文章都只讨论精确到 0.0 到 1.0 的小数级别的插值。我想插入整数整数,不管它们有多大,或者是否有负数或其他什么。我用线性插值完成了这个:
如何在 FORTRAN 中实现二维插值,其中数据如下所示。 x 和 y 是两个坐标,z 是依赖于它们的值 x 间隔均匀但 y 不均匀间隔且 y 的最大值 对应于 x 的统一值不断增加。 在不损失太多准
在彼得阿尔弗雷德的 article关于多元散点数据插值,他提到,从各种方案中,只有少数方案真正受到从业者的欢迎。例如,他命名为 Shepard 方法和 Hardy Multiquadrics。但那篇文
我不清楚图像处理中重采样和插值之间的区别。如果我有一个 geotiff 并且我想提高它的分辨率,我应该使用重采样方法,例如最近邻,对吗?例如,我发现 gdalwarp 函数可以做到这一点。 插值方法,
对于这个有点令人困惑的标题,我感到很抱歉,但我不确定如何更清楚地总结这一点。 我有两组 X,Y 数据,每组对应一个总体值。它们是从原始数据中相当密集地采样的。我正在寻找一种方法,为任何给定的 Y 找到
我很抱歉标题有点困惑,但我不确定如何更清楚地总结这一点。 我有两组X,Y数据,每组对应一个大概的整体值。它们是从原始数据中相当密集地采样的。我正在寻找的是一种方法,可以为我已有的集合之间的值找到任何给
我是 D3 新手,正在尝试一些图表。在使用 D3 V4 构建折线图时,我遇到了以下错误。 d3.line(...).x(...).y(...).interpolate is not a functio
问候, 在我正在开发的网络应用程序中,我想做如下事情: 我有一个 bean class Gene{ String geneid; String sequence; .. } // EL express
有什么方法可以将 Angular 的 $interpolate 与数组而不是对象一起使用? 示例代码: var exp = $interpolate('Hello {{name}}!'); var r
我是编程新手,我会尝试编写一个线性插值函数: from bisect import bisect_left def interpolate((x_list, y_list), x_test):
我启动了一个带有共享元素的场景转换的 Activity,它工作正常。 ActivityOptionsCompat options = ActivityOptionsCompat.makeSceneTr
背景分析 在传统的html页面中我们可以定义变量吗?当然不可以,那我们假如希望通过变量的方式实现页面内容的数据操作也是不可以的。当然我们可以在服务端通过定义html标签库方式,然后以html作为模
我在 wikipedia 上阅读了关于双三次插值的信息.我遇到了变量 t这是没有定义的。 等式是: 谁能告诉我这个变量是什么意思以及它的常用值是什么? 最佳答案 t 是 0 到 1 之间的任何数字。
我是一名优秀的程序员,十分优秀!