Uniform Distribution in Data Science
Last Updated :
06 Jun, 2025
Uniform Distribution also known as the Rectangular Distribution is a type of Continuous Probability Distribution where all outcomes in a given interval are equally likely. Unlike Normal Distribution which have varying probabilities across their range, Uniform Distribution has a constant probability density throughout the interval which results in a "flat" distribution.
1. Events and Interval
Uniform Distribution applies to events that are equally likely within a fixed interval [a,b]. This interval can represent time, space or any continuous measurement. The events within this interval are random and independent but they all have the same likelihood of occurring.
Example: If a fair die is rolled each side (1 to 6) is equally likely to appear which represents a discrete uniform distribution. In contrast, a continuous uniform distribution could model the outcome of a randomly chosen time within a 24-hour day where every moment has the same probability.
2. Probability Density Function (PDF)
PDF for a Uniform Distribution is a constant value across the entire interval [a,b]. This is because every point in the interval is equally likely to be chosen. Formula for the Uniform PDF is:
f(x) = \frac{1}{b - a}, \quad a \leq x \leq b
For any x outside the interval [a,b] the PDF is zero:
f(x) = 0, \quad \text{for} \ x < a \ \text{or} \ x > b
Example: For a uniform distribution on the interval [0,25] the PDF is:
f(x) = \frac{1}{25 - 0} = 0.04, \quad 0 \leq x \leq 25
This means every value between 0 and 25 has the same probability of occurring.
3. Cumulative Distribution Function (CDF)
CDF provides the probability that the random variable is less than or equal to a specific value x. For a Uniform Distribution, the CDF is calculated as the cumulative sum of the PDF over the range from a to x and its formula is:
F(x) = \begin{cases} 0, & \text{if} \ x < a \\\frac{x - a}{b - a}, & \text{if} \ a \leq x \leq b \\1, & \text{if} \ x > b\end{cases}
Example: For a Uniform Distribution between a = 0 and b = 25 the CDF is:
F(x) = \begin{cases} 0, & \text{if} \ x < 0 \\\frac{x}{25}, & \text{if} \ 0 \leq x \leq 25 \\1, & \text{if} \ x > 25\end{cases}
This shows that for any value of x, the probability that X ≤ x is simply the proportion of the interval up to x.
Properties of the Uniform Distribution
1. Expected Value (Mean)
The expected value of a Uniform Distribution represents the central tendency of the distribution. It is the average of the lower and upper bounds of the interval which is calculated as:
E[X] = \frac{a + b}{2}
Example: For a Uniform Distribution with a=0 and b=25, the expected value is:
E[X] = \frac{0 + 25}{2} = 12.5
This means the average value of the random variable X is 12.5.
2. Variance
The variance of the Uniform Distribution measures the spread of values around the mean and its formula is:
Var(X) = \frac{(b - a)^2}{12}
Example: For a=0 and b=25, the variance is:
Var(X) = \frac{(25 - 0)^2}{12} = \frac{625}{12} \approx 52.08
This tells us how much the values are expected to deviate from the mean.
3. Standard Deviation
The standard deviation is the square root of the variance and provides a measure of the dispersion of the distribution. The formula for the standard deviation is:
\sigma = \sqrt{Var(X)} = \frac{b - a}{\sqrt{12}}
Example: For a=0 and b=25:
\sigma = \frac{25 - 0}{\sqrt{12}} \approx 7.21
Let’s apply the Uniform Distribution to a real-world scenario. Suppose the current measured in a piece of copper wire is uniformly distributed over the interval [0,25]. We can calculate the PDF, mean, variance, standard deviation and CDF.
1. PDF: f(x) = \frac{1}{25 - 0} = 0.04, \quad 0 \leq x \leq 25
2. Expected Value: E[X] = \frac{0 + 25}{2} = 12.5
3. Variance: Var(X) = \frac{(25 - 0)^2}{12} = \frac{625}{12} \approx 52.08
4. Standard Deviation: \sigma = \frac{25 - 0}{\sqrt{12}} \approx 7.21
5. CDF: F(x) =\begin{cases} 0, & \text{if} \ x < 0 \\\frac{x}{25}, & \text{if} \ 0 \leq x \leq 25 \\1, & \text{if} \ x > 25\end{cases}
Here we implement the Uniform Distribution in Python and we will be using NumPy and Matplotlib libraries to and visualize random samples from a uniform distribution.
Python
import numpy as np
import matplotlib.pyplot as plt
a = 0
b = 25
samples = np.random.uniform(a, b, 1000)
plt.hist(samples, bins=30, density=True, alpha=0.6, color='g')
x = np.linspace(a, b, 1000)
plt.plot(x, np.ones_like(x) / (b - a), 'r-', lw=2)
plt.title('Uniform Distribution PDF')
plt.xlabel('X')
plt.ylabel('Probability Density')
plt.show()
Output:
ResultUniform Distribution is used in various real-world scenarios where all outcomes within a specific interval are equally likely, some common applications include:
- Random Sampling: In simulations, random numbers are drawn from a Uniform Distribution to simulate random behavior.
- Quality Control: In manufacturing, they models variations in product measurements when there’s no systematic bias.
- Lottery and Gaming: The distribution is used to model random number selection in lottery games or shuffling cards.
- Random Time Intervals: If an event is equally likely to occur at any moment within a given time frame this can model the time of occurrence.
Mastering the Uniform Distribution helps us with a tool for modeling scenarios where each outcome within a specified range is equally likely and it provides a solid foundation for applications in random sampling, quality control and simulations.
Similar Reads
Engineering Mathematics Tutorials Engineering mathematics is a vital component of the engineering discipline, offering the analytical tools and techniques necessary for solving complex problems across various fields. Whether you're designing a bridge, optimizing a manufacturing process, or developing algorithms for computer systems,
3 min read
Matrix and Determinants
MatricesMatrices are key concepts in mathematics, widely used in solving equations and problems in fields like physics and computer science. A matrix is simply a grid of numbers, and a determinant is a value calculated from a square matrix.Example: \begin{bmatrix} 6 & 9 \\ 5 & -4 \\ \end{bmatrix}_{2
3 min read
Different Operations on MatricesFor an introduction to matrices, you can refer to the following article: Matrix Introduction In this article, we will discuss the following operations on matrices and their properties: Matrices AdditionMatrices SubtractionMatrices MultiplicationMatrices Addition: The addition of two matrices A m*n a
11 min read
Representation of Relation in Graphs and MatricesUnderstanding how to represent relations in graphs and matrices is fundamental in engineering mathematics. These representations are not only crucial for theoretical understanding but also have significant practical applications in various fields of engineering, computer science, and data analysis.
8 min read
Determinant of Matrix with Solved ExamplesThe determinant of a matrix is a scalar value that can be calculated for a square matrix (a matrix with the same number of rows and columns). It serves as a scaling factor that is used for the transformation of a matrix.It is a single numerical value that plays a key role in various matrix operation
15+ min read
Properties of DeterminantsProperties of Determinants are the properties that are required to solve various problems in Matrices. There are various properties of the determinant that are based on the elements, rows, and columns of the determinant. These properties help us to easily find the value of the determinant. Suppose w
10 min read
Row Echelon FormRow Echelon Form (REF) of a matrix simplifies solving systems of linear equations, understanding linear transformations, and working with matrix equations. A matrix is in Row Echelon form if it has the following properties:Zero Rows at the Bottom: If there are any rows that are completely filled wit
4 min read
Eigenvalues and EigenvectorsEigenvalues and eigenvectors are fundamental concepts in linear algebra, used in various applications such as matrix diagonalization, stability analysis and data analysis (e.g., PCA). They are associated with a square matrix and provide insights into its properties.Eigen value and Eigen vectorTable
10 min read
System of Linear EquationsA system of linear equations is a set of two or more linear equations involving the same variables. Each equation represents a straight line or a plane and the solution to the system is the set of values for the variables that satisfy all equations simultaneously.Here is simple example of system of
5 min read
Matrix DiagonalizationMatrix diagonalization is the process of reducing a square matrix into its diagonal form using a similarity transformation. This process is useful because diagonal matrices are easier to work with, especially when raising them to integer powers.Not all matrices are diagonalizable. A matrix is diagon
8 min read
LU DecompositionLU decomposition or factorization of a matrix is the factorization of a given square matrix into two triangular matrices, one upper triangular matrix and one lower triangular matrix, such that the product of these two matrices gives the original matrix. It is a fundamental technique in linear algebr
6 min read
Finding Inverse of a Square Matrix using Cayley Hamilton Theorem in MATLABMatrix is the set of numbers arranged in rows & columns in order to form a Rectangular array. Here, those numbers are called the entries or elements of that matrix. A Rectangular array of (m*n) numbers in the form of 'm' horizontal lines (rows) & 'n' vertical lines (called columns), is calle
4 min read
Sequence and Series
Binomial TheoremBinomial theorem is a fundamental principle in algebra that describes the algebraic expansion of powers of a binomial. According to this theorem, the expression (a + b)n where a and b are any numbers and n is a non-negative integer. It can be expanded into the sum of terms involving powers of a and
15+ min read
Sequences and SeriesA sequence is an ordered list of numbers following a specific rule. Each number in a sequence is called a "term." The order in which terms are arranged is crucial, as each term has a specific position, often denoted as anâ, where n indicates the position in the sequence.For example:2, 5, 8, 11, 14,
10 min read
Finding nth term of any Polynomial SequenceGiven a few terms of a sequence, we are often asked to find the expression for the nth term of this sequence. While there is a multitude of ways to do this, In this article, we discuss an algorithmic approach which will give the correct answer for any polynomial expression. Note that this method fai
4 min read
Mathematics | Sequence, Series and SummationsSequences, series, and summations are fundamental concepts of mathematical analysis and it has practical applications in science, engineering, and finance.Table of ContentWhat is Sequence?Theorems on SequencesProperties of SequencesWhat is Series?Properties of SeriesTheorems on SeriesSummation Defin
8 min read
Calculus
Limits in CalculusIn mathematics, a limit is a fundamental concept that describes the behaviour of a function or sequence as its input approaches a particular value. Limits are used in calculus to define derivatives, continuity, and integrals, and they are defined as the approaching value of the function with the inp
12 min read
Indeterminate FormsAssume a function F(x)=\frac{f(x)}{g(x)} which is undefined at x=a but it may approach a limit as x approaches a. The process of determining such a limit is known as evaluation of indeterminate forms. The L' Hospital Rule helps in the evaluation of indeterminate forms. According to this rule- \lim_{
3 min read
Limits, Continuity and DifferentiabilityLimits, Continuity, and Differentiation are fundamental concepts in calculus. They are essential for analyzing and understanding function behavior and are crucial for solving real-world problems in physics, engineering, and economics.Table of ContentLimitsKey Characteristics of LimitsExample of Limi
10 min read
Cauchy's Mean Value TheoremCauchy's Mean Value theorem provides a relation between the change of two functions over a fixed interval with their derivative. It is a special case of Lagrange Mean Value Theorem. Cauchy's Mean Value theorem is also called the Extended Mean Value Theorem or the Second Mean Value Theorem.According
7 min read
Lagrange's Mean Value TheoremLagrange's Mean Value Theorem (LMVT) is a fundamental result in differential calculus, providing a formalized way to understand the behavior of differentiable functions. This theorem generalizes Rolle's Theorem and has significant applications in various fields of engineering, physics, and applied m
9 min read
Rolle's Mean Value TheoremRolle's theorem one of the core theorem of calculus states that, for a differentiable function that attains equal values at two distinct points then it must have at least one fixed point somewhere between them where the first derivative of the function is zero.Rolle's Theorem and the Mean Value Theo
8 min read
Taylor SeriesA Taylor series represents a function as an infinite sum of terms, calculated from the values of its derivatives at a single point.Taylor series is a powerful mathematical tool used to approximate complex functions with an infinite sum of terms derived from the function's derivatives at a single poi
8 min read
Maclaurin seriesPrerequisite - Taylor theorem and Taylor series We know that formula for expansion of Taylor series is written as: f(x)=f(a)+\sum_{n=1}^{\infty}\frac{f^n(a)}{n!}(x-a)^n Now if we put a=0 in this formula we will get the formula for expansion of Maclaurin series. T hus Maclaurin series expansion can b
2 min read
Euler's FormulaEuler's formula holds a prominent place in the field of mathematics. It aids in establishing the essential link between trigonometric functions and complex exponential functions. It is a crucial formula used for solving complicated exponential functions. It is also known as Euler's identity. It has
5 min read
Chain Rule: Theorem, Formula and Solved ExamplesThe Chain Rule is a way to find the derivative of composite functions. It is one of the basic rules used in mathematics for solving differential equations. It helps us to find the derivative of composite functions such as (3x2 + 1)4, (sin 4x), e3x, (ln x)2, and others. Only the derivatives of compos
8 min read
Inverse functions and composition of functionsInverse Functions - In mathematics a function, a, is said to be an inverse of another, b, if given the output of b a returns the input value given to b. Additionally, this must hold true for every element in the domain co-domain(range) of b. In other words, assuming x and y are constants, if b(x) =
3 min read
Definite Integral | Definition, Formula & How to CalculateA definite integral is an integral that calculates a fixed value for the area under a curve between two specified limits. The resulting value represents the sum of all infinitesimal quantities within these boundaries. i.e. if we integrate any function within a fixed interval it is called a Definite
8 min read
Mathematics | Indefinite IntegralsAntiderivative - Definition :A function ∅(x) is called the antiderivative (or an integral) of a function f(x) of ∅(x)' = f(x). Example : x4/4 is an antiderivative of x3 because (x4/4)' = x3. In general, if ∅(x) is antiderivative of a function f(x) and C is a constant.Then, {∅
4 min read
Application of Derivative - Maxima and MinimaDerivatives have many applications, like finding rate of change, approximation, maxima/minima and tangent. In this section, we focus on their use in finding maxima and minima.Note: If f(x) is a continuous function, then for every continuous function on a closed interval has a maximum and a minimum v
6 min read
Summation FormulasIn mathematics, the summation is the basic addition of a sequence of numbers, called addends or summands; the result is their sum or total. The summation of an explicit sequence is denoted as a succession of additions. For example, the summation of (1, 3, 4, 7) can be written as 1 + 3 + 4 + 7, and t
6 min read
Statistics and Numerical Methods
Mean, Variance and Standard DeviationMean, Variance and Standard Deviation are fundamental concepts in statistics and engineering mathematics, essential for analyzing and interpreting data. These measures provide insights into data's central tendency, dispersion, and spread, which are crucial for making informed decisions in various en
10 min read
Mathematics - Law of Total ProbabilityProbability theory is the branch of mathematics concerned with the analysis of random events. It provides a framework for quantifying uncertainty, predicting outcomes, and understanding random phenomena. In probability theory, an event is any outcome or set of outcomes from a random experiment, and
12 min read
Probability Distribution - Function, Formula, TableA probability distribution is a mathematical function or rule that describes how the probabilities of different outcomes are assigned to the possible values of a random variable. It provides a way of modeling the likelihood of each outcome in a random experiment.While a frequency distribution shows
15+ min read
Bayes' TheoremBayes' Theorem is a mathematical formula used to determine the conditional probability of an event based on prior knowledge and new evidence. It adjusts probabilities when new information comes in and helps make better decisions in uncertain situations.Bayes' Theorem helps us update probabilities ba
13 min read
Conditional ProbabilityConditional probability defines the probability of an event occurring based on a given condition or prior knowledge of another event. Conditional probability is the likelihood of an event occurring, given that another event has already occurred. In probability, this is denoted as A given B, expresse
12 min read
Probability Distribution
Engineering Math Practice Problems