本文簡要介紹 python 語言中 scipy.special.voigt_profile
的用法。
用法:
scipy.special.voigt_profile(x, sigma, gamma, out=None) = <ufunc 'voigt_profile'>#
沃伊特簡介。
Voigt 分布是具有標準差
sigma
的一維正態分布和 half-width 處的一維柯西分布 (half-maximumgamma
) 的卷積。如果
sigma = 0
,則返回柯西分布的 PDF。相反,如果gamma = 0
,則返回正態分布的 PDF。如果sigma = gamma = 0
,則x = 0
的返回值為Inf
,所有其他x
的返回值為0
。- x: array_like
真正的參數
- sigma: array_like
正態分布部分的標準差
- gamma: array_like
柯西分布部分的half-maximum處的half-width
- out: ndarray,可選
函數值的可選輸出數組
- 標量或 ndarray
給定參數處的 Voigt 剖麵
參數 ::
返回 ::
注意:
可以用 Faddeeva 函數來表示
其中 是 Faddeeva 函數。
參考:
例子:
計算
sigma=1
和gamma=1
在點 2 處的函數。>>> from scipy.special import voigt_profile >>> import numpy as np >>> import matplotlib.pyplot as plt >>> voigt_profile(2, 1., 1.) 0.09071519942627544
通過為 x 提供 NumPy 數組來計算多個點的函數。
>>> values = np.array([-2., 0., 5]) >>> voigt_profile(values, 1., 1.) array([0.0907152 , 0.20870928, 0.01388492])
繪製不同參數集的函數。
>>> fig, ax = plt.subplots(figsize=(8, 8)) >>> x = np.linspace(-10, 10, 500) >>> parameters_list = [(1.5, 0., "solid"), (1.3, 0.5, "dashed"), ... (0., 1.8, "dotted"), (1., 1., "dashdot")] >>> for params in parameters_list: ... sigma, gamma, linestyle = params ... voigt = voigt_profile(x, sigma, gamma) ... ax.plot(x, voigt, label=rf"$\sigma={sigma},\, \gamma={gamma}$", ... ls=linestyle) >>> ax.legend() >>> plt.show()
目視驗證 Voigt 分布確實是作為正態分布和柯西分布的卷積而出現的。
>>> from scipy.signal import convolve >>> x, dx = np.linspace(-10, 10, 500, retstep=True) >>> def gaussian(x, sigma): ... return np.exp(-0.5 * x**2/sigma**2)/(sigma * np.sqrt(2*np.pi)) >>> def cauchy(x, gamma): ... return gamma/(np.pi * (np.square(x)+gamma**2)) >>> sigma = 2 >>> gamma = 1 >>> gauss_profile = gaussian(x, sigma) >>> cauchy_profile = cauchy(x, gamma) >>> convolved = dx * convolve(cauchy_profile, gauss_profile, mode="same") >>> voigt = voigt_profile(x, sigma, gamma) >>> fig, ax = plt.subplots(figsize=(8, 8)) >>> ax.plot(x, gauss_profile, label="Gauss: $G$", c='b') >>> ax.plot(x, cauchy_profile, label="Cauchy: $C$", c='y', ls="dashed") >>> xx = 0.5*(x[1:] + x[:-1]) # midpoints >>> ax.plot(xx, convolved[1:], label="Convolution: $G * C$", ls='dashdot', ... c='k') >>> ax.plot(x, voigt, label="Voigt", ls='dotted', c='r') >>> ax.legend() >>> plt.show()
相關用法
- Python SciPy special.exp1用法及代碼示例
- Python SciPy special.expn用法及代碼示例
- Python SciPy special.ncfdtri用法及代碼示例
- Python SciPy special.gamma用法及代碼示例
- Python SciPy special.y1用法及代碼示例
- Python SciPy special.y0用法及代碼示例
- Python SciPy special.ellip_harm_2用法及代碼示例
- Python SciPy special.i1e用法及代碼示例
- Python SciPy special.smirnovi用法及代碼示例
- Python SciPy special.ker用法及代碼示例
- Python SciPy special.ynp_zeros用法及代碼示例
- Python SciPy special.k0e用法及代碼示例
- Python SciPy special.j1用法及代碼示例
- Python SciPy special.logsumexp用法及代碼示例
- Python SciPy special.expit用法及代碼示例
- Python SciPy special.polygamma用法及代碼示例
- Python SciPy special.nbdtrik用法及代碼示例
- Python SciPy special.nbdtrin用法及代碼示例
- Python SciPy special.seterr用法及代碼示例
- Python SciPy special.ncfdtr用法及代碼示例
- Python SciPy special.pdtr用法及代碼示例
- Python SciPy special.expm1用法及代碼示例
- Python SciPy special.shichi用法及代碼示例
- Python SciPy special.smirnov用法及代碼示例
- Python SciPy special.stdtr用法及代碼示例
注:本文由純淨天空篩選整理自scipy.org大神的英文原創作品 scipy.special.voigt_profile。非經特殊聲明,原始代碼版權歸原作者所有,本譯文未經允許或授權,請勿轉載或複製。