问题
I am trying to plot a clothoid function using SciPy. Here is the syntax for the Fresnel integrals but I cannot understand what are the arguments x
, out1
, out2
in scipy.special.fresnel(x[, out1, out2])
? Formulas in the description are about t
and z
, which are not in the function.
回答1:
The arguments out1
and out2
are optional. You can use
s, c = fresnel(x)
The argument z
shown in the docstring is the x
argument. That is an unfortunate discrepancy--the docstring should be consistent with the function signature.
The arguments out1
and out2
can be used if you already have arrays in which you want to put the results of the function call. This allows you to save memory by reusing existing arrays.
Note that the scipy implementation of the function scales the argument by pi/2. See the notes about this in the wikipedia article: http://en.wikipedia.org/wiki/Fresnel_integral
This script will generate the first plot shown in the wikipedia article:
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()
来源:https://stackoverflow.com/questions/13308573/scipy-what-are-the-arguments-in-scipy-special-fresnelx-out1-out2