本文簡要介紹 python 語言中 scipy.special.diric
的用法。
用法:
scipy.special.diric(x, n)#
周期正弦函數,也稱為狄利克雷函數。
狄利克雷函數定義為:
diric(x, n) = sin(x * n/2) / (n * sin(x / 2)),
其中 n 是一個正整數。
- x: array_like
輸入數據
- n: int
定義周期性的整數。
- diric: ndarray
參數 ::
返回 ::
例子:
>>> import numpy as np >>> from scipy import special >>> import matplotlib.pyplot as plt
>>> x = np.linspace(-8*np.pi, 8*np.pi, num=201) >>> plt.figure(figsize=(8, 8)); >>> for idx, n in enumerate([2, 3, 4, 9]): ... plt.subplot(2, 2, idx+1) ... plt.plot(x, special.diric(x, n)) ... plt.title('diric, n={}'.format(n)) >>> plt.show()
以下示例演示
diric
給出矩形脈衝的傅裏葉係數的幅度(對符號和縮放進行模)。抑製實際上為 0 的值的輸出:
>>> np.set_printoptions(suppress=True)
創建一個長度為 m 的信號 x 和 k 個:
>>> m = 8 >>> k = 3 >>> x = np.zeros(m) >>> x[:k] = 1
使用 FFT 計算 x 的傅裏葉變換,並檢查係數的大小:
>>> np.abs(np.fft.fft(x)) array([ 3. , 2.41421356, 1. , 0.41421356, 1. , 0.41421356, 1. , 2.41421356])
現在使用
diric
.我們乘以k考慮到不同的縮放約定numpy.fft.fft和diric
:>>> theta = np.linspace(0, 2*np.pi, m, endpoint=False) >>> k * special.diric(theta, k) array([ 3. , 2.41421356, 1. , -0.41421356, -1. , -0.41421356, 1. , 2.41421356])
相關用法
- Python SciPy special.digamma用法及代碼示例
- Python SciPy special.dawsn用法及代碼示例
- 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用法及代碼示例
注:本文由純淨天空篩選整理自scipy.org大神的英文原創作品 scipy.special.diric。非經特殊聲明,原始代碼版權歸原作者所有,本譯文未經允許或授權,請勿轉載或複製。