dpnp.kaiser
- dpnp.kaiser(M, beta, *, device=None, usm_type=None, sycl_queue=None)[source]
Return the Kaiser window.
The Kaiser window is a taper formed by using a Bessel function.
For full documentation refer to
numpy.kaiser
.- Parameters:
M (int) -- Number of points in the output window. If zero or less, an empty array is returned.
beta (float) -- Shape parameter for window.
device ({None, string, SyclDevice, SyclQueue, Device}, optional) --
An array API concept of device where the output array is created. device can be
None
, a oneAPI filter selector string, an instance ofdpctl.SyclDevice
corresponding to a non-partitioned SYCL device, an instance ofdpctl.SyclQueue
, or adpctl.tensor.Device
object returned bydpnp.ndarray.device
.Default:
None
.usm_type ({None, "device", "shared", "host"}, optional) --
The type of SYCL USM allocation for the output array.
Default:
None
.sycl_queue ({None, SyclQueue}, optional) --
A SYCL queue to use for output array allocation and copying. The sycl_queue can be passed as
None
(the default), which means to get the SYCL queue from device keyword if present or to use a default queue.Default:
None
.
- Returns:
out -- The window, with the maximum value normalized to one (the value one appears only if the number of samples is odd).
- Return type:
dpnp.ndarray of shape (M,)
See also
dpnp.bartlett
Return the Bartlett window.
dpnp.blackman
Return the Blackman window.
dpnp.hamming
Return the Hamming window.
dpnp.hanning
Return the Hanning window.
Notes
The Kaiser window is defined as
\[w(n) = I_0\left( \beta \sqrt{1-\frac{4n^2}{(M-1)^2}} \right)/I_0(\beta)\]with
\[\quad -\frac{M-1}{2} \leq n \leq \frac{M-1}{2},\]where \(I_0\) is the modified zeroth-order Bessel function.
The Kaiser can approximate many other windows by varying the beta parameter.
beta
Window shape
0
Rectangular
5
Similar to a Hamming
6
Similar to a Hanning
8.6
Similar to a Blackman
A beta value of
14
is probably a good starting point. Note that as beta gets large, the window narrows, and so the number of samples needs to be large enough to sample the increasingly narrow spike, otherwise NaNs will get returned.Examples
>>> import dpnp as np >>> np.kaiser(12, 14) array([7.72686638e-06, 3.46009173e-03, 4.65200161e-02, 2.29737107e-01, 5.99885281e-01, 9.45674843e-01, 9.45674843e-01, 5.99885281e-01, 2.29737107e-01, 4.65200161e-02, 3.46009173e-03, 7.72686638e-06])
Creating the output array on a different device or with a specified usm_type:
>>> x = np.kaiser(3, 14) # default case >>> x, x.device, x.usm_type (array([7.72686638e-06, 9.99999941e-01, 7.72686638e-06]), Device(level_zero:gpu:0), 'device')
>>> y = np.kaiser(3, 14, device="cpu") >>> y, y.device, y.usm_type (array([7.72686638e-06, 9.99999941e-01, 7.72686638e-06]), Device(opencl:cpu:0), 'device')
>>> z = np.kaiser(3, 14, usm_type="host") >>> z, z.device, z.usm_type (array([7.72686638e-06, 9.99999941e-01, 7.72686638e-06]), Device(level_zero:gpu:0), 'host')