- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
是否有可能在 Python 中找到基于 De Boor 方法的平滑样条曲线?用于数据近似。
之前我在 matlab 中使用了平滑样条曲线,我需要在 python 中使用完全相同的算法。
最佳答案
您可能想使用scipy.interpolate.CubicSpline 。下面的例子直接取自文档:
在此示例中,三次样条用于对采样的正弦曲线进行插值。可以看出,样条连续性属性对于一阶和二阶导数成立,并且仅对于三阶导数违反。还有另一个可用的例子;不确定你到底需要什么。
这是生成该图所需的代码:
from scipy.interpolate import CubicSpline
import matplotlib.pyplot as plt
import numpy as np
x = np.arange(10)
y = np.sin(x)
cs = CubicSpline(x, y)
xs = np.arange(-0.5, 9.6, 0.1)
plt.figure(figsize=(6.5, 4))
plt.plot(x, y, 'o', label='data')
plt.plot(xs, np.sin(xs), label='true')
plt.plot(xs, cs(xs), label="S")
plt.plot(xs, cs(xs, 1), label="S'")
plt.plot(xs, cs(xs, 2), label="S''")
plt.plot(xs, cs(xs, 3), label="S'''")
plt.xlim(-0.5, 9.5)
plt.legend(loc='lower left', ncol=2)
plt.show()
您还可以查看scipy.interpolate.splrep和 scipy.interpolate.InterpolatedUnivariateSpline 。此外,还有一个github repository这可能会有帮助。您可以将这些方法与您使用的 Matlab 函数进行比较并选择合适的方法。
关于python - 平滑样条 De Boor 方法,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43237043/
是否有可能在 Python 中找到基于 De Boor 方法的平滑样条曲线?用于数据近似。 之前我在 matlab 中使用了平滑样条曲线,我需要在 python 中使用完全相同的算法。 最佳答案 您可
我目前正在尝试实现用于绘制贝塞尔曲线的 Cox De Boor 算法。我已经设法通过设定的度数、控制点的数量和预定义的节点向量生成一些可以接受的东西,但我想调整我的代码,以便它可以在给定任意数量的控制
我知道这是一个有点“请做我的功课”的问题,但我正在尝试按照此处的说明实现 De Boor 算法:http://en.wikipedia.org/wiki/De_Boor's_algorithm 我有一
维基百科为我们提供了 de Boor 算法的 Python 实现: def deBoor(k, x, t, c, p): """ Evaluates S(x). Args
我已经为此工作了几个星期,但一直无法让我的算法正常工作,我束手无策。这是我所取得成就的说明: 如果一切正常,我希望最后会出现一个完美的圆形/椭圆形。 每次添加新的控制点(黄色)时,我的样本点(白色)都
我正在服务器上使用 RmiServiceExporter 并在客户端上使用 RmiProxyFactoryBean 创建 Spring Boot 应用程序。当我启动服务器时,一切似乎都正常,我得到 [
我是一名优秀的程序员,十分优秀!