VOOZH about

URL: https://www.geeksforgeeks.org/python/compute-the-histogram-of-a-set-of-data-using-numpy-in-python/

⇱ Compute the histogram of a set of data using NumPy in Python - GeeksforGeeks


  • Courses
  • Tutorials
  • Interview Prep

Compute the histogram of a set of data using NumPy in Python

Last Updated : 15 Jul, 2025

Numpy provides us the feature to compute the Histogram for the given data set using NumPy.histogram() function. The formation of histogram depends on the data set, whether it is predefined or randomly generated.

Syntax : numpy.histogram(data, bins=10, range=None, normed=None, weights=None, density=None)

Case 1: Computing the Numpy Histogram with the help of Random Data set

Output:

👁 Image

In the above example, we created a random data set using np.random.randint() and plot the Numpy Histogram

Case 2: Computing the Numpy Histogram with the help of Pre-defined Data set

👁 Image

In the above example, we take a predefined data set and plot the Numpy Histogram.

Comment
Article Tags: