Multiple Random Variables
Tags: statistics, machinelearning, datascience, maths
Published: 2022-02-06 21:17:57

Topics Covered — Joint PMF and Marginal PMF of 2 or more Random Variables.
Prerequisite — Random Variables
This article is basically the math behind the PMF of random variables and how it can be used if more than one are involved.

## Joint PMF

Assume X and Y are Discrete Random Variables defined in the same probability space.
Range of X = Tx
Range of Y = Ty
Then Fₓᵧ(x,y) is a function from Tx × Ty to [0,1]
F(t₁ , t₂) = P( X=t₁ and Y=t₂ ) such that t₁ ∈ Tx and t₂ ∈ Ty
P(X,Y) means P(X and Y) here
When we write Joint PMF it is written usually in form of a table or matrix
Let’s take an example to understand it better.
**Tossing a fair coin twice.**
Let Xᵢ = 1 if i’th toss is heads and Xᵢ = 0 if i’th toss is tails
Here i= 1,2
Fₓ₁ₓ₂(0,0) = P(X₁=0 , X₂=0)=1/2 * 1/2 = 1/4
Fₓ₁ₓ₂(0,1)= P(X₁=0 , X₂=1) = 1/2 *1/2 = 1/4
The same info in Tabular form -
![tabular form](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/e4r0ix943b81beilpzcv.png)

Since all entries have equal probability a proper distinction cannot be seen in the various PMFs so let’s take another example to understand this better
**Random Number Less than 100**
X is the Units place and Y is the remainder of the number when divided by 4
Like in case of 31 X=1 and Y=3
Fₓᵧ(0,0) = P(X=0, Y=0) = P(Number ending in 0 and Divisible by 4)
So the set of numbers in this category are {00,20,40,60,80}
P({0,20,40,60,80}) = 5/100 or 1/20
Similarly
Fₓᵧ(4,2) = P( X=4 , Y=2) = P(Number ends in 4 and has 2 as remainder)
Set of numbers = {14,34,54,74,94}
P({14,34,54,74,94}) = 5/100=1/20
Right now it seems like the above case where all values where equal but this is really not the case for this example
Fₓᵧ(1,0) = P( X=1 , Y=0) = P(Number ends in 1 and has no remainder)
Set of numbers = ϕ
Because there is no such number
So, P(X=1,Y=0)=0
![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/m7krod2ekruqwxo6q6is.png)

Such a table can be formed depicting all values of Fₓᵧ
Also if you note sum of one column or row depicts the probability of that individual event happening
That is what we will be discussing in the next part of this article

## Marginal PMF

Suppose X and Y are jointly distributed discrete random variables
with joint PMF Fₓᵧ . The PMF of the individual random variables X and Y are called
as marginal PMFs. It can be shown that![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/fbbb1yao0zp7brh9rss7.png)
 

**Important Point- Marginal PMF is Simple PMF if the other variable did not exist.**
That math above looks weirdly complex but all it means is if we form a PMF table and add a row or column then it gives us the probability of that individual event
For example in the above example we had formed the table
![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/cqjwc4qnj0d13koqfa61.png)
 

Add all the probabilities of column 0 ( Remainder of number is 0)
Probability of this happening is 1/4 because remainder can be one of 0,1,2,3 this is also shown by sum of all rows in that column.
So we can say
Fₓ₂(0)=1/4 →1/20 + 1/20 + 1/20 + 1/20 + 1/20

Similarly for rows
Probability of Units place being 5 is 1/10 and it is same as sum of all columns associated with that row.
Fₓ₁(5)=1/10 → 1/20 + 1/20

## Joint PMF of more than two discrete random variables

Suppose X₁, X₂, . . . , Xₙ are discrete random variables defined in the same probability space. Let the range of Xᵢ be Tₓᵢ. The joint PMF of Xᵢ , denoted by Fₓ₁,ₓ₂,….ₓₙ, is a function from Tₓ₁ × Tₓ₂ × . . . × Tₓₙ to [0, 1] defined as
Fₓ₁,ₓ₂,….ₓₙ = P(X₁ = t₁, X₂ = t₂, . . . , Xn = tₙ); tᵢ ∈ Tₓ
This is exactly like using the “and” operator to get all Variables together and find their Joint PMF.

## Marginal PMF in case of more than two discrete random variables

Suppose X₁, X₂, . . . , Xₙ are jointly distributed discrete random variables with joint PMF Fₓ₁,ₓ₂,….ₓₙ The PMF of the individual random variables X₁, X₂, . . . , Xₙ are called as marginal PMFs. It can be shown in form of
![formula](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/idzflj95v0btg9umr2uk.png)
 

In simple terms the above math jargon says — Take the Joint PMF of all the given variables except the one who’s marginal PMF is being found.
For example -
Let’s take 3 random variables X₁ , X₂ and X₃
To find marginal PMF of X₁. Find the Joint PMF of X₂ and X₃
**This can also be grouped up and is called Marginalisation**
![formula](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/n7kgssz15bmd5jsyri7n.png)
 
The above formula’s simplification is Sum everything that is not needed.
X₁, X₂, X₃ and X₄ are random variables forming a Joint PMF
To find Marginalised PMF of X₁ and X₃ we find Joint PMF of X₂ and X₄

Stay Tuned

####