python - 在python中进行样条插值的更快方法
问题描述
我正在尝试用 3 度样条插值 30 个点,如下所示:
from sympy import interpolating_spline
domain_points = [0.01, 0.01888888888888889, 0.027777777777777776, 0.03666666666666667, 0.04555555555555556, 0.05444444444444445, 0.06333333333333332, 0.07222222222222222, 0.0811111111111111, 0.09, 0.09888888888888889, 0.10777777777777778, 0.11666666666666665, 0.12555555555555556, 0.13444444444444445, 0.14333333333333334, 0.15222222222222223, 0.16111111111111112, 0.17, 0.30833333333333335, 0.44666666666666666, 0.5850000000000001, 0.7233333333333334, 0.8616666666666667, 1.0, 2.5, 4.0, 5.5, 7.0, 8.5]
range_points = list(map(lambda x: x-1/x, domain_points))
interpolating_spline(3, x, domain_points, range_points)
这在我的机器上大约需要 1 分钟 42 秒。我做错了什么让这这么慢吗?有没有办法加快速度,或者有一个更快的样条插值库,这样我就可以插值更多的点?
解决方案
如果您只想数字插值,请使用 scipy
https://docs.scipy.org/doc/scipy/reference/tutorial/interpolate.html#spline-interpolation
Sympy 用于代数操作。
推荐阅读
- c# - 多对多与相关 ViewModel DTO C#
- c++ - 如何比较两个字符数组并在两者之间存储不同的值
- r - 根据 R 中的列值自动为 3D 散点图点分配颜色
- sql - 如何在 SSIS 或 SQL 中使用不同的数据集向不同的收件人发送电子邮件?
- html - 仅在文本的换行部分应用 css
- c - 前几页写入美光 MT25Q 闪存设备失败
- webpack - Watch Ignore Plugin 已使用与 API 模式不匹配的选项对象进行初始化
- java - 事务编号的自动增量(Eclipse Java)
- microsoft-graph-api - Microsoft 图形 api 搜索不返回所有文件
- bash - 不打印 FIFO 内容