A random variable is a key concept in statistics that connects theoretical probability with real-world data. It is a function that assigns a real number to each outcome in the sample space of a random experiment.
For example:
When you roll a die, the outcome is one of the six faces. A random variable can assign a number (like 1 to 6) to each of these outcomes, allowing us to analyze the results using statistical methods.
There are two possible outcomes, modeled as random variablesWe define a random variable as a function that maps from the sample space of an experiment to the real numbers. Mathematically, a Random Variable is expressed as,
X: S →R
Where:
- X is a Random Variable (It is usually denoted using a capital letter)
- S is Sample Space
- R is a Set of Real Numbers
Random variables are generally represented by capital letters like X and Y. This is explained by the example below:
Random Variable Examples
Example 1: If two unbiased coins are tossed, then find the random variable associated with that event.
Solution:
Suppose Two (unbiased) coins are tossed
X = number of heads. [X is a random variable or function]
Here, the sample space S = {HH, HT, TH, TT}
Suppose a random variable X takes m different values, X = {x1, x2, x3,..., xm}, with corresponding probabilities P(X = xi) = pi, where 1 ≤ i ≤ m.
The probabilities must satisfy the following conditions :
- 0 ≤ pi ≤ 1; where 1 ≤ i ≤ m
- p1 + p2 + p3 + ....... + pm = 1 or we can say 0 ≤ pi ≤ 1 and ∑pi = 1
Example 2: Suppose a die is thrown (X = outcome of the dice) and the sample space S = {1, 2, 3, 4, 5, 6}.
Solution:
The output of the function will be:
- P(X = 1) = 1/6
- P(X = 2) = 1/6
- P(X = 3) = 1/6
- P(X = 4) = 1/6
- P(X = 5) = 1/6
- P(X = 6) = 1/6
This also satisfies the condition ∑6i=1 P(X = i) = 1, since:
P(X = 1) + P(X = 1) + P(X = 2) + P(X = 3) + P(X = 4) + P(X = 5) + P(X = 6) = 6 × 1/6 = 1
Variate
A variate is a general term often used interchangeably with a random variable, particularly in contexts where the random variable is not yet fully specified by a particular probabilistic experiment. It is an abstract concept that represents a real-valued outcome of a random process, but is not necessarily tied to a specific probability distribution.
It has the same properties as a random variable, such as a defined range of possible values. The range of values that a random variable X can take is denoted as Rx ( range of X ). Individual values within this range are called quantiles. The probability of the random variable X taking a specific value x is written as P(X = x).
Types of Random Variables
Random variables are of two types, that are as follows:
Types Of Random Variable Discrete Random Variable
A Discrete Random Variable takes on a finite or countably infinite number of values. The probability function associated with a discrete random variable is called as Probability Mass Function.
PMF(Probability Mass Function)
If X is a discrete random variable and the PMF of X is P(xi), then
- 0 ≤ pi ≤ 1
- ∑p(xi) = 1, where the sum is taken over all possible values of x
Discrete Random Variables Example
Example: Let S = {0, 1, 2}
Find the value of P (X = 0)
Solution:
We know that the sum of all probabilities is equal to 1. And P (X = 0) be P1
P1 + 0.3 + 0.5 = 1
P1 = 0.2
Then, P (X = 0) is 0.2
Continuous Random Variable
A Continuous Random Variable takes on an infinite number of values. The probability function associated with it is said to be PDF (Probability Density Function).
PDF (Probability Density Function)
If X is a continuous random variable. P (x < X < x + dx) = f(x)dx then,
- 0 ≤ f(x) ≤ 1; for all x
- ∫ f(x) dx = 1 over all values of x
Then P (X) is said to be a PDF of the distribution.
Example: Find the value of P (1 < X < 2) f(x) = kx3; 0 ≤ x ≤ 3 = 0. Otherwise, f(x) is a density function.
Solution:
If a function f is said to be a density function, then the sum of all probabilities is equal to 1.
Since it is a continuous random variable Integral value is 1 overall sample space s.
∫ f(x) dx = 1
∫ kx3 dx = 1
K[x4]/4 = 1
Given interval, 0 ≤ x ≤ 3 = 0
K[34 – 04]/4 = 1
K(81/4) = 1
K = 4/81
Thus,
P (1 < X < 2) = k × [X4]/4
P = 4/81 × [16-1]/4
P = 15/81
There are two main random variable formulas,
- Mean of a Random Variable
- Variance of a Random Variable
Let's learn about the same in detail.
Mean of a Random Variable
For any random variable X where P is its respective probability, we define its mean as,
Mean(μ) = ∑ X.P
Where,
- X is the random variable that consists of all possible values.
- P is the probability of the respective variables
Variance of a Random Variable
The variance of a random variable tells us how the random variable is spread about the mean value of the random variable. The variance of the Random Variable is calculated using the formula,
Var(x) = σ2 = E(X2) - {E(X)}2
Where,
Random Variable Functions
For any random variable X if it assume the values x1, x2,...xn where the probability corresponding to each random variable is P(x1), P(x2),...P(xn), then the expected value of the variable is,
Expectation of X, E(x) = ∑ x.P(x)
Now, for any new random variable Y in which the random variable X is its input, i.e., Y = f(X), then the cumulative distribution function of Y is,
Fy(Y) = P(g(X) ≤ y)
Probability Distribution and Random Variable
For a random variable, its probability distribution is calculated using three methods,
- Theoretical listing of outcomes and probabilities of the outcomes.
- Experimental listing of outcomes followed by their observed relative frequencies.
- Subjective listing of outcomes followed by their subjective probabilities.
The probability of a random variable X that takes values x is defined using a probability function of X that is denoted by f (x) = f (X = x).
Random Variables in Computer Science
Random variables are important in computer science for dealing with uncertainty and chance.
- They are used to study the average behavior of algorithms that use random steps, such as QuickSort.
- In machine learning, they help describe input data, predictions, and errors.
- Simulations use them to model events like customer arrivals or data flow in a network.
- In cybersecurity, random variables help create strong, unpredictable keys.
- They are also useful in checking how well data structures like hash tables perform.
- In networking, they help predict delays and traffic.
- Even in games and animation, random variables create random actions and natural-looking effects.
Solved Questions on Random Variable
Here are some of the solved examples on a Random variable. Learn random variables by practicing these solved examples.
Question 1: Find the mean value for the continuous random variable, f(x) = x2, 1 ≤ x ≤ 3
Solution:
Given,
f(x) = x2
1 ≤ x ≤ 3
E(x) = \int_{1}^{3} x \cdot f(x) \, dx
E(x) = \int_{1}^{3} x \cdot x^2 \, dx
E(x) = \int_{1}^{3} x^3 \, dx
E(x) = [x4/4]31
E(x) = 1/4 × {34- 14} = 1/4 × {81 - 1}
E(x) = 1/4 × {80} = 20
Question 2: Find the mean value for the continuous random variable, f(x) = ex, 1 ≤ x ≤ 3
Solution:
Given,
f(x) = ex
1 ≤ x ≤ 3
E(x) = \int_{1}^{3} x \cdot f(x) \, dx
E(x) = \int_{1}^{3} x \cdot e^x \, dx
E(x) = [x.ex - ex]31
E(x) = [ex(x - 1)]31
E(x) = e3(2) - e(0)
Question 3: Given the discrete random variable X with the following probability distribution:
Find the mean value (or expected value) of the random variable X.
Solution:
To find the mean value (expected value) of a discrete random variable X, we use the formula:
Using the relation: E(X) = μX = x1P(x1) + x2P(x2) + ... + xnP(xn)
E(X) = ∑i Xi · P(Xi)
The expected value E(X), or mean μX of a discrete random variable X
E(X) = μX = ∑ [ xi * P(xi) ]
E(X) = 1 * 0.1 + 2 * 0.2 + 3 * 0.4 + 4 * 0.3
E(X) = 0.100 + 0.400 + 1.200 + 1.200 = 2.900
E(X) = 2.900
Question 4: Given the discrete random variable X with the following probability distribution:
Suppose a discrete random variable X represents the number of defective items in a sample of 10 items from a batch of 100 items. The possible values of X are 0, 3, 5, and 7 defective items, with the following probability distribution:
Find the mean value (or expected value) of the random variable X.
Solution:
The formula for the mean (or expected value) of a discrete random variable X is:
E(X) = ∑i Xi ⋅ P(Xi)
The expected value E(X), or mean μX of a discrete random variable X
E(X) = μX = ∑ [ xi * P(xi) ]
E(X) = 0 * 0.2 + 3 * 0.5 + 5 * 0.2 + 7 * 0.1
E(X) = 0.000 + 1.500 + 1.000 + 0.700 = 3.200
E(X) = 3.200
Practice Problems on Random Variables
Question 1: Find the mean value for the continuous random variable, f(x) = x3, 1 ≤ x ≤ 5
Question 2: Find the mean value for the continuous random variable, f(x) = x, 1 ≤ x ≤ 4.
Question 3: Given the discrete random variable X with the following probability distribution:
Find the mean value (or expected value) of the random variable X.
Question 4: Given the discrete random variable X with the following probability distribution:
Find the mean value (or expected value) of the random variable X.
Answer:-
- 624.8.
- 21.
- 2.4.
- 1.7.
Random Variables: Definition, Types, Examples & Formula
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
Linear Algebra
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
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 & Series
Calculus
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
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
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
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
Probability & Statistics
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
Conditional ProbabilityConditional probability defines the probability of an event occurring based on a given condition or prior knowledge of another event. It is the likelihood of an event occurring, given that another event has already occurred. In probability, this is denoted as A given B, expressed as P(A | B), indica
12 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
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
13 min read
Covariance and CorrelationCovariance and correlation are the two key concepts in Statistics that help us analyze the relationship between two variables. Covariance measures how two variables change together, indicating whether they move in the same or opposite directions. Relationship between Independent and dependent variab
6 min read
Practice Questions