Random Variable
Random variable is a fundamental concept in statistics that bridges the gap between theoretical probability and real-world data. random variable in statistics is a function that assigns a real value to an outcome in the sample space of a random experiment. For example: if you roll a die, you can assign a number to each possible outcome.
There are two basic types of random variables,
- Discrete Random Variables (which take on specific values)
- Continuous Random Variables (assume any value within a given range)
In this article, we will learn about random variable statistics, their types, random variable examples, and others in detail.
What is a Random Variable?
Random Variable Probability is a mathematical concept that assigns numerical values to outcomes of a sample space. They can describe the outcomes of objective randomness (like tossing a coin) or subjective randomness(results of a cricket game).
There are two types of Random Variables- Discrete and Continuous.
A random variable is considered a discrete random variable when it takes specific, or distinct values within an interval. Conversely, if it takes a continuous range of values, then it is classified as a continuous random variable.
Random Variable Definition
Random variable in statistics is a variable whose possible values are numerical outcomes of a random phenomenon. It is a function that assigns a real number to each outcome in the sample space of a random experiment.
We define a random variable as a function that maps from the sample space of an experiment to the real numbers. Mathematically, Random Variable is expressed as,
X: S →R
where,
- X is Random Variable (It is usually denoted using capital letter)
- S is Sample Space
- R is Set of Real Numbers
Table of Content
- What is a Random Variable?
- Random Variable Example
- Variate
- Types of Random Variable
- Discrete Random Variable
- Continuous Random Variable
- Random Variable Formulas
- Random Variable Functions
- Probability Distribution and Random Variable
- Random Variable Example with Solutions
- Practice Problems on Random Variable
Random variables are generally represented by capital letters like X and Y. This is explained by the example below:
Random Variable Example
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}
Example 2
Suppose a random variable X takes m different values i.e. sample space
X = {x1, x2, x3………xm} with 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
Hence possible values for random variable X are 0, 1, 2.
X = {0, 1, 2} where m = 3
- P(X = 0) = (Probability that number of heads is 0) = P(TT) = 1/2×1/2 = 1/4
- P(X = 1) = (Probability that number of heads is 1) = P(HT | TH) = 1/2×1/2 + 1/2×1/2 = 1/2
- P(X = 2) = (Probability that number of heads is 2) = P(HH) = 1/2×1/2 = 1/4
Here, you can observe that, (0 ≤ p1, p2, p3 ≤ 1/2)
p1 + p2 + p3 = 1/4 + 2/4 + 1/4 = 1
For example,
Suppose a dice is thrown (X = outcome of the dice). Here, the sample space S = {1, 2, 3, 4, 5, 6}. 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
Variate
A variate is a generalization of the concept of a random variable that is defined without reference to a particular type of probabilistic experiment.
It has the same properties as random variables and is denoted by capital letters (commonly X).
The possible values a random variable X can take are its range, denoted R_X. Individual values within this range are called quantiles, and the probability of X taking a specific value x is written as P(X=x).
Types of Random Variable
Random variables are of two types that are,
- Discrete Random Variable
- Continuous Random Variable

Discrete Random Variable
A Discrete Random Variable takes on a finite number of values. The probability function associated with it is said to be PMF.
PMF(Probability Mass Function)
If X is a discrete random variable and the PMF of X is P(xi), then
- 0 ≤ pi ≤ 1
- ∑pi = 1 where the sum is taken over all possible values of x
Discrete Random Variables Example
Example: Let S = {0, 1, 2}
|
xi |
0 |
1 |
2 |
|---|---|---|---|
|
Pi(X = xi) |
P1 |
0.3 |
0.5 |
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
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.
Continuous Random Variables Example
Find the value of P (1 < X < 2)
Such that,
- 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
Random Variable Formulas
There are two main random variable formulas,
- Mean of Random Variable
- Variance of Random Variable
Let’s learn about the same in detail,
Mean of 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 consist of all possible values.
- P is the probability of respective variables
Variance of Random Variable
The variance of a random variable tells us how the random variable is spread about the mean value of the random variable. Variance of Random Variable is calculated using the formula,
Var(x) = σ2 = E(X2) – {E(X)}2
where,
- E(X2) = ∑X2P
- E(X) = ∑XP
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 with their observed relative frequencies.
- Subjective listing of outcomes followed with their subjective probabilities.
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).
There are various probability distributions that are,
- Binomial Distribution
- Poisson Distribution
- Bernoulli’s Distribution
- Exponential Distribution
- Normal Distribution
People Also Read:
Random Variable Example with Solutions
Here are some of the solved examples on Random variable. Learn random variables by practicing these solved examples.
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) = ∫31 x.f(x)dx
E(x) = ∫31 x.x2.dx
E(x) = ∫31 x3.dx
E(x) = [x4/4]31
E(x) = 1/4{34– 14} = 1/4{81 – 1}
E(x) = 1/4{80} = 20
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) = ∫31 x.f(x)dx
E(x) = ∫31 x.ex.dx
E(x) = [x.ex – ex]31
E(x) = [ex(x – 1)]31
E(x) = e3(2) – e(0)
3. Find the mean value for the continuous random variable, f(x) = x2, 1 ≤ x ≤ 3
Solution :
f(x) = x^2, 1 ≤ x ≤ 3
Mean = ∫(x^3)dx / ∫(x^2)dx from 1 to 3
= [(1/4)x^4]₁³ / [(1/3)x^3]₁³
= (81/4 – 1/4) / (27/3 – 1/3)
= 20 / 26/3
= 20 * 3/26 = 60/26 ≈ 2.31
4. Find the mean value for the continuous random variable, f(x) = 2x + 1, 0 ≤ x ≤ 4
Solution :
f(x) = 2x + 1, 0 ≤ x ≤ 4
Mean = ∫(x(2x+1))dx / ∫(2x+1)dx from 0 to 4
= [(2/3)x^3 + (1/2)x^2]₀⁴ / [x^2 + x]₀⁴
= (170/3) / 20
= 17/6 ≈ 2.83
5. Find the mean value for the continuous random variable, f(x) = x3, -1 ≤ x ≤ 2
Solution :
f(x) = x3, -1 ≤ x ≤ 2
Mean = ∫(x^4)dx / ∫(x^3)dx from -1 to 2
= [(1/5)x^5]₋₁² / [(1/4)x^4]₋₁²
= (32/5 + 1/5) / (16/4 + 1/4)
= 33/5 / 17/4
= 334 / (517) ≈ 1.55
6. Find the mean value for the continuous random variable, f(x) = √x, 1 ≤ x ≤ 9
Solution :
f(x) = √x, 1 ≤ x ≤ 9
Mean = ∫(x√x)dx / ∫(√x)dx from 1 to 9
= [(2/5)x^(5/2)]₁⁹ / [(2/3)x^(3/2)]₁⁹
= (486 – 2/5) / (18 – 2/3)
≈ 5.2
7. Find the mean value for the continuous random variable, f(x) = 3x2 – 2x, 0 ≤ x ≤ 3
Solution :
f(x) = 3x^2 – 2x, 0 ≤ x ≤ 3
Mean = ∫(x(3x^2-2x))dx / ∫(3x^2-2x)dx from 0 to 3
= [(3/4)x^4 – (2/3)x^3]₀³ / [x^3 – x^2]₀³
= (81/4 – 18) / (27 – 9)
= 27/4 / 18 = = 27/72 = 3/8 ≈ 0.375
8. Find the mean value for the continuous random variable, f(x) = sin(x), 0 ≤ x ≤ π
Solution :
f(x) = sin(x), 0 ≤ x ≤ π
Mean = ∫(x sin(x))dx / ∫(sin(x))dx from 0 to π
= [-x cos(x) + sin(x)]₀ᵖⁱ / [-cos(x)]₀ᵖⁱ
= (π + 1) / 2
≈ 2.07
9. Find the mean value for the continuous random variable, f(x) = ex, 0 ≤ x ≤ 2
Solution :
f(x) = e^x, 0 ≤ x ≤ 2
Mean = ∫(x e^x)dx / ∫(e^x)dx from 0 to 2
= [x e^x – e^x]₀² / [e^x]₀²
= (2e^2 – e^2 + 1) / (e^2 – 1)
≈ 1.54
10. Find the mean value for the continuous random variable, f(x) = ln(x), 1 ≤ x ≤ e
Solution :
f(x) = ln(x), 1 ≤ x ≤ e
Mean = ∫(x ln(x))dx / ∫(ln(x))dx from 1 to e
= [(1/4)x^2(2ln(x)-1)]₁ᵉ / [x ln(x) – x]₁ᵉ
= (e^2/2 – 1/4) / (e – 1)
≈ 1.95
Practice Problems on Random Variable
1. A coin is flipped 5 times. Define the random variable as the number of heads. Find the probability distribution.
2. A bag contains 6 red and 4 blue balls. A ball is drawn. Define the random variable as the color of the ball. Find the probability distribution.
3. Roll two dice. Define the random variable as the sum of the outcomes. Find the probability distribution.
4. A box contains 10 defective items out of 50. Define the random variable as the number of defective items in a random sample of 5. Find the expected value.
5. Flip a coin until you get a head. Define the random variable as the number of flips. Find the probability distribution.
6. A dice is rolled twice. Define the random variable as the difference between the numbers rolled. Find the expected value.
7. A survey finds the heights of 100 students. Define the random variable as the height of a student. Find the variance.
8. Draw a card from a deck of 52 cards. Define the random variable as the card drawn (numbered). Find the expected value.
9. A spinner has numbers 1 through 8. Define the random variable as the number spun. Find the probability of getting a number greater than 5.
10. A lottery has 100 tickets. Define the random variable as the winning ticket number. Find the probability of drawing a specific number.
Conclusion
In probability and statistics, a random variable acts like a translator. It takes the unpredictable outcomes of an experiment (like flipping a coin) and assigns numbers to them (heads = 1, tails = 0). Random Variables serve as the bridge between abstract mathematical concepts and real-world phenomena, allowing us to model, analyze, and make predictions about random processes. These numbers come in two flavors: discrete (specific values like number of successful trials) or continuous (ranges of values like waiting time). By having these numerical labels, we can analyze the uncertainty of the experiment using powerful tools from probability and statistics.
Random Variable – FAQs
What is a Random Variable?
A random variable in statistics are the variables that represent all the possible outcome of a Random Variable.
What are Two Types of Random Variable?
There are two types of Random Variables and that are,
- Continuous Random Variable
- Discrete Random Variable
What is Mean of a Random Variable?
Mean of Random Variable is calculated using the formula,
- Mean of a Discrete Random Variable: E[X] = ∑x.P(X = x)
- Mean of a Continuous Random Variable: E[X] = ∫ x.f(x).dx
How is a Random Variable Used?
Random variables are used in probability and statistics to model and analyze the outcomes of random phenomena, calculate probabilities, and determine expected values.
Can a Random Variable Be Negative?
Yes, a random variable can be negative if the numerical values it assigns to outcomes include negative numbers, depending on the context of the experiment or phenomenon.
How Do You Find the Expected Value of a Random Variable?
The expected value of a random variable is found by multiplying each possible outcome by its probability and summing all these products.
What is the Difference Between a Random Variable and a Probability Distribution?
A random variable is a function that assigns numerical values to outcomes, while a probability distribution describes how probabilities are distributed over the values of the random variable.
How Can You Calculate Probabilities Using a Random Variable?
Probabilities can be calculated using the probability distribution of the random variable, which provides the probabilities for the variable’s different possible values.
What is a Probability Mass Function (PMF)?
For discrete random variables, the PMF is a function that gives the probability that the random variable is exactly equal to some value.
What is a Probability Density Function (PDF)?
For continuous random variables, the PDF is a function that describes the relative likelihood for this random variable to take on a given value.
How Do Random Variables Relate to Statistical Analysis?
Random variables are foundational in statistical analysis, allowing for the quantification and analysis of random phenomena, hypothesis testing, and data modeling.
What is Variance of a Random Variable?
Variance of Random Variable is calculated using the formula,
- Variance of a Discrete Random Variable: V[X] = ∑(x – μ)2.P(X = x)
- Variance of a Continuous Random Variable: V[X] = ∫ (x – μ)2.f(x).dx
What is Random Variables Expected Value?
Expected value of a Random Variable is the weighted average of all possible values of the variable. Weight of the random variable is the probability of random variable at specific values.
What are Continuous Random Variables?
Continuous Random Variables are type of random variable in probability theory and statistics that are used to represent the continuous probability of the distribution of a function.

