r""" Return the normalized sinc function. The sinc function is equal to :math:`\sin(\pi x)/(\pi x)` for any argument :math:`x\ne 0`. ``sinc(0)`` takes the limit value 1, making ``sinc`` not only everywhere continuous but also infinitely differentiable. .. note:: Note t
(x)
| 3631 | |
| 3632 | @array_function_dispatch(_sinc_dispatcher) |
| 3633 | def sinc(x): |
| 3634 | r""" |
| 3635 | Return the normalized sinc function. |
| 3636 | |
| 3637 | The sinc function is equal to :math:`\sin(\pi x)/(\pi x)` for any argument |
| 3638 | :math:`x\ne 0`. ``sinc(0)`` takes the limit value 1, making ``sinc`` not |
| 3639 | only everywhere continuous but also infinitely differentiable. |
| 3640 | |
| 3641 | .. note:: |
| 3642 | |
| 3643 | Note the normalization factor of ``pi`` used in the definition. |
| 3644 | This is the most commonly used definition in signal processing. |
| 3645 | Use ``sinc(x / np.pi)`` to obtain the unnormalized sinc function |
| 3646 | :math:`\sin(x)/x` that is more common in mathematics. |
| 3647 | |
| 3648 | Parameters |
| 3649 | ---------- |
| 3650 | x : ndarray |
| 3651 | Array (possibly multi-dimensional) of values for which to calculate |
| 3652 | ``sinc(x)``. |
| 3653 | |
| 3654 | Returns |
| 3655 | ------- |
| 3656 | out : ndarray |
| 3657 | ``sinc(x)``, which has the same shape as the input. |
| 3658 | |
| 3659 | Notes |
| 3660 | ----- |
| 3661 | The name sinc is short for "sine cardinal" or "sinus cardinalis". |
| 3662 | |
| 3663 | The sinc function is used in various signal processing applications, |
| 3664 | including in anti-aliasing, in the construction of a Lanczos resampling |
| 3665 | filter, and in interpolation. |
| 3666 | |
| 3667 | For bandlimited interpolation of discrete-time signals, the ideal |
| 3668 | interpolation kernel is proportional to the sinc function. |
| 3669 | |
| 3670 | References |
| 3671 | ---------- |
| 3672 | .. [1] Weisstein, Eric W. "Sinc Function." From MathWorld--A Wolfram Web |
| 3673 | Resource. http://mathworld.wolfram.com/SincFunction.html |
| 3674 | .. [2] Wikipedia, "Sinc function", |
| 3675 | https://en.wikipedia.org/wiki/Sinc_function |
| 3676 | |
| 3677 | Examples |
| 3678 | -------- |
| 3679 | >>> import matplotlib.pyplot as plt |
| 3680 | >>> x = np.linspace(-4, 4, 41) |
| 3681 | >>> np.sinc(x) |
| 3682 | array([-3.89804309e-17, -4.92362781e-02, -8.40918587e-02, # may vary |
| 3683 | -8.90384387e-02, -5.84680802e-02, 3.89804309e-17, |
| 3684 | 6.68206631e-02, 1.16434881e-01, 1.26137788e-01, |
| 3685 | 8.50444803e-02, -3.89804309e-17, -1.03943254e-01, |
| 3686 | -1.89206682e-01, -2.16236208e-01, -1.55914881e-01, |
| 3687 | 3.89804309e-17, 2.33872321e-01, 5.04551152e-01, |
| 3688 | 7.56826729e-01, 9.35489284e-01, 1.00000000e+00, |
| 3689 | 9.35489284e-01, 7.56826729e-01, 5.04551152e-01, |
| 3690 | 2.33872321e-01, 3.89804309e-17, -1.55914881e-01, |