Understand numpy.hamming() with Examples – NumPy Tutorial

By | July 26, 2021

In this tutorial, we will use some examples to show you how to use numpy.hamming() functions.


numpy.hamming() function is defined as:


It can create a hamming window.

How to compute hamming window?

Hamming window is calculated as follows:

How to compute hamming window?

Here is an image for hamming window when M = 51

hamming window example

How to use numpy.hamming()?

Here is an example:

import numpy as np
win = np.hamming(12)

Run this codoe, you will get:

[0.08       0.15302337 0.34890909 0.60546483 0.84123594 0.98136677
 0.98136677 0.84123594 0.60546483 0.34890909 0.15302337 0.08      ]

In audio processing, we often add use hamming window to the frame to reduce signal discontinuity at the beginning and end of the frame.