Uniform Distribution in NumPy Last Updated : 22 Apr, 2025 Comments Improve Suggest changes Like Article Like Report A Uniform Distribution is used when all the numbers in a range have the same chance of being picked. For example, if we choose a number between 10 and 20 and every number in that range is just as likely as any other. In Python's NumPy library you can generate random numbers following a Uniform Distribution using the numpy.random.uniform() method. The syntax is:Syntax: numpy.random.uniform(low=0.0, high=1.0, size=None)low : The lower bound of the range (inclusive). Default is 0.0.high : The upper bound of the range (exclusive). Default is 1.0.size : The shape of the returned array.Example 1: Generate a Single Random NumberIn this example we can see how to generate a single random number from a default Uniform Distribution (low=0, high=1): Python import numpy as np random_number = np.random.uniform() print(random_number) Output:0.1466964230422637To generate multiple random numbers: Python random_numbers = np.random.uniform(size=5) print(random_numbers) Output:[0.72798597 0.35286575 0.10228773 0.56598948 0.03552713]Visualizing the Uniform DistributionVisualizing the generated numbers helps in understanding their behavior. Let's see a example to plot a histogram of random numbers using numpy.random.uniform function. Python import numpy as np import matplotlib.pyplot as plt import seaborn as sns low = 10 high = 20 size = 1000 data = np.random.uniform(low=low, high=high, size=size) sns.histplot(data, bins=30, kde=False, color='skyblue', edgecolor='black') plt.title(f"Uniform Distribution (Range: {low} to {high})") plt.xlabel("Value") plt.ylabel("Frequency") plt.grid(True) plt.show() Output:Uniform DistributionThe image above shows a Uniform Distribution between 10 and 20. This means every number in that range is equally likely to happen. The bars in the histogram show that the values from 10 to 20 appear about the same number of times. Comment More infoAdvertise with us Next Article Uniform Distribution in NumPy J Jitender_1998 Follow Improve Article Tags : Python Python-numpy Python numpy-Random Practice Tags : python Similar Reads Python - Uniform Distribution in Statistics scipy.stats.uniform() is a Uniform continuous random variable. It is inherited from the of generic methods as an instance of the rv_continuous class. It completes the methods with details specific for this particular distribution. Parameters : q : lower and upper tail probability x : quantiles loc : 2 min read Normal Distribution in NumPy The Normal Distribution also known as the Gaussian Distribution is one of the most important distributions in statistics and data science. It is widely used to model real-world phenomena such as IQ scores, heart rates, test results and many other naturally occurring events.numpy.random.normal() Meth 2 min read Python - Uniform Discrete Distribution in Statistics scipy.stats.randint() is a uniform discrete random variable. It is inherited from the of generic methods as an instance of the rv_discrete class. It completes the methods with details specific for this particular distribution. Parameters : x : quantiles loc : [optional]location parameter. Default = 2 min read Generate Random Numbers From The Uniform Distribution using NumPy Random numbers are the numbers that cannot be predicted logically and in Numpy we are provided with the module called random module that allows us to work with random numbers. To generate random numbers from the Uniform distribution we will use random.uniform() method of random module. Syntax: nump 1 min read NumPy Introduction NumPy(Numerical Python) is a fundamental library for Python numerical computing. It provides efficient multi-dimensional array objects and various mathematical functions for handling large datasets making it a critical tool for professionals in fields that require heavy computation.Table of ContentK 7 min read Like