我正在尝试使用 SciPy 绘制回旋函数。 Here是菲涅尔积分的语法,但我无法理解参数是什么 x
, out1
, out2
在scipy.special.fresnel(x[, out1, out2])
?描述中的公式约为t
和z
,它们不在函数中。
最佳答案
参数out1
和out2
是可选的。您可以使用
s, c = fresnel(x)
文档字符串中显示的参数 z
是 x
参数。这是一个不幸的差异——文档字符串应该与函数签名一致。
如果您已经有要在其中放置函数调用结果的数组,则可以使用参数 out1
和 out2
。这允许您通过重用现有数组来节省内存。
请注意,该函数的 scipy 实现按 pi/2 缩放参数。请参阅维基百科文章中有关此内容的注释:http://en.wikipedia.org/wiki/Fresnel_integral
此脚本将生成维基百科文章中显示的第一个图:
import numpy as np
from scipy.special import fresnel
import matplotlib.pyplot as plt
t = np.linspace(0, 5.0, 201)
ss, cc = fresnel(t / np.sqrt(np.pi / 2))
scaled_ss = np.sqrt(np.pi / 2) * ss
scaled_cc = np.sqrt(np.pi / 2) * cc
plt.plot(t, scaled_cc, 'g--', t, scaled_ss, 'r-', linewidth=2)
plt.grid(True)
plt.show()
关于numpy - SciPy: `scipy.special.fresnel(x[, out1, out2])` 中的参数是什么?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13308573/