Random Variables - Definition, Types, Examples & Formula

Download as pdf or txt
Download as pdf or txt
You are on page 1of 19

Random Variable

Last Updated : 17 Jun, 2024

A 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.

Random variables can have specific values or any value in a range.

There are two basic types of random variables,

Discrete Random Variables


Continuous Random Variables

In this article, we will learn about random variable statistics, their


types, random variable examples, and others in detail.


Table of Content
What is a Random Variable?
Random Variable Definition
Random Variable Example
Variate
Types of Random Variable
Discrete Random Variable
PMF(Probability Mass Function)
Discrete Random Variables Example
Continuous Random Variable
PDF (Probability Density Function)
Continuous Random Variables Example
Random Variable Formulas
Mean of Random Variable
Variance of Random Variable
Random Variable Functions
Probability Distribution and Random Variable
Random Variable Example with Solutions
Example 1
Example 2
Practice Problems on Random Variable

What is a Random Variable?


A 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

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

Random variables are generally represented by capital letters like X


and Y. This is explained by the example below:

School Guide Mathematics Number System and Arithmetic Algebra Trigonometry Statist
Random Variable Example

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 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:

Probability Distribution Function


Expected Value
Variance and Standard Deviation
Continous and Discrete Uniform Distribution Formula

Random Variable Example with Solutions


Here are some of the solved examples on Random variable. Learn
random variables by practicing these solved examples.

Example 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

Example 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)

E(x) = 2e3

Practice Problems on Random Variable


Practice random variables by solving these practice questions on
random variable.

P1. Find the mean value for the continuous random variable, f(x) =
3x3, 0 ≤ x ≤ 9

P2. Find the mean value for the continuous random variable, f(x) = x +
sin x, 0 ≤ x ≤ π/4

P3. Find the variance value for the continuous random variable, f(x) =
2ex +x, -2 ≤ x ≤ 2

P4. Find the variance value for the continuous random variable, f(x) =
5 + x.tanx, -π/4 ≤ x ≤ π/4

Summary – Random Variable


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). 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.
FAQs on Random Variable

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.

Are you a student in Computer Science or an employed professional


looking to take up the GATE 2025 Test? Of course, you can get a
good score in it but to get the best score our GATE CS/IT 2025 - Self-
Paced Course is available on GeeksforGeeks to help you with its
preparation. Get comprehensive coverage of all topics of GATE,
detailed explanations, and practice questions for study. Study at your
pace. Flexible and easy-to-follow modules. Do well in GATE to
enhance the prospects of your career. Enroll now and let your journey
to success begin!

GeeksforGeeks 43

Previous Article Next Article


Calculate the average, variance and Difference between Parametric and
standard deviation in Python using Non-Parametric Methods
NumPy

Similar Reads

Class 12 RD Sharma Solutions - Chapter 32 Mean and Varianc…


Calculate the mean deviation from the median of the following
frequency distribution :Question 1(i): Find the mean and standard…
15+ min read

Class 12 RD Sharma Solutions - Chapter 32 Mean and Varianc…


Question 13: Two cards are selected at random from a box which
contains five cards numbered 1,1,2,2, and 3. Let X denote the sum an…
11 min read

Class 12 RD Sharma Solutions- Chapter 32 Mean and Varianc…


Question 1. Which of the following distributions of probabilities of
random variables are their probability distributions? i. X3210-…
7 min read

Class 12 RD Sharma Solutions - Chapter 32 Mean and Varianc…


Question 16. Two cards are drawn successively with replacement from
well-shuffled pack of 52 cards. Find the probability distribution of…
7 min read

Discrete Random Variable


Discrete Random Variables are an essential concept in probability
theory and statistics. Discrete Random Variables play a crucial role in…
15 min read

View More Articles

Article Tags : Engineering Mathematics GATE CS Mathematics School Learning


A-143, 9th Floor, Sovereign
Corporate Tower, Sector-136, Noida,
Uttar Pradesh - 201305

Company Languages
About Us Python
Legal Java
In Media C++
Contact Us PHP
Advertise with us GoLang
GFG Corporate Solution SQL
Placement Training Program R Language
GeeksforGeeks Community Android Tutorial
Tutorials Archive

DSA Data Science & ML


Data Structures Data Science With Python
Algorithms Data Science For Beginner
DSA for Beginners Machine Learning Tutorial
Basic DSA Problems ML Maths
DSA Roadmap Data Visualisation Tutorial
Top 100 DSA Interview Problems Pandas Tutorial
DSA Roadmap by Sandeep Jain NumPy Tutorial
All Cheat Sheets NLP Tutorial
Deep Learning Tutorial

Web Technologies Python Tutorial


HTML Python Programming Examples
CSS Python Projects
JavaScript Python Tkinter
TypeScript Web Scraping
ReactJS OpenCV Tutorial
NextJS Python Interview Question
Bootstrap Django
Web Design

Computer Science DevOps


Operating Systems Git
Computer Network Linux
Database Management System AWS
Software Engineering Docker
Digital Logic Design Kubernetes
Engineering Maths Azure
Software Development GCP
Software Testing DevOps Roadmap

System Design Inteview Preparation


High Level Design Competitive Programming
Low Level Design Top DS or Algo for CP
UML Diagrams Company-Wise Recruitment Process
Interview Guide Company-Wise Preparation
Design Patterns Aptitude Preparation
OOAD Puzzles
System Design Bootcamp
Interview Questions

School Subjects GeeksforGeeks Videos


Mathematics DSA
Physics Python
Chemistry Java
Biology C++
Social Science Web Development
English Grammar Data Science
Commerce CS Subjects
World GK

@GeeksforGeeks, Sanchhaya Education Private Limited, All rights reserved

You might also like