Introduction to Random Variables

Random Variable

A random variable is a mapping
X : Ω→R
that assigns a real number X(ω) to each outcome ω

Getting proper intuitions of X is very important to understand probability. Let us try to understand random variables with an example.

Let the experiment be flipping a coin twice and X be the number of heads. Then
P(X=0) = P({TT}) = 1/4,
P(X=1) = P({HT, TH}) = 1/2 and
P(X=2) = P({HH}) = 1/4.

We summarize the information as follows:

ω
(outcome)
P({ω})X(ω)
TT1/40
TH1/4
HT1/41
HH1/4 2
x
(number of heads)
P(X = x)
01/4
11/2
21/4

Note that X denotes a random variable and x denotes a possible value of X.

You can relate a random variable with a feature in a dataset.
The feature in a dataset is a term equivalent to a random variable. However remember that the dataset is not population but the sample of the population. If the dataset has N rows, we can say that we have N realizations of one or more random variable.


Distribution Function and Probability function

Cumulative Distribution Function

The cumulative distribution function (or distribution function), CDF, is the function
FX : R→[0,1] defined by
FX(x) = P(X ≤ x)

The cumulative distribution function of x is the sum of probabilities of all those values of random variables that are less than or equal to x. Every CDF is non-decreasing and right continuous. If X is discrete and is defined for x1, x2, … then CDF of X will be discontinuous at points x1, x2, …

Continuing with the above example, CDF for the experiment of flipping a coin twice.

Could you understand how we derived the above function? Let’s see.
According to the definition of CDF, FX(x) = P(X ≤ x) i.e. CDF of x is the sum of probabilities of all those values of a random variable that are less than or equal to x. Therefore,
FX(0) = P(X=0) = 1/4
FX(1) = P(X=0) + P(X=1) = 1/4+ 1/2 = 3/4
FX(2) = P(X=0) + P(X=1) + P(X=2) = 1

Now note that even if the probabilities are defined at a discrete point, the CDF is defined for all the values. Therefore FX(1.6) = 0.75.
Using this definition we conclude the above function and plot its graph as follows.
cdf graph

A function F mapping real line to [0, 1] is a CDF for some probability measure P if and only if it satisfies the following three conditions:

(i) F is non-decreasing i.e. x1 < x2 implies that F(x1) ≤ F(x2).
(ii) F is normalized: lim x→-∞F(x) = 0 and limx→∞F(x) = 1.
(iii) F is right-continuous, i.e. F(x) = F(x+) for all x, where
F(x+) = limy→x, y>x F(y)


Probability Function or Probability Mass Function (For Discrete R.V.)

For discrete random variables,
We define the probability function or probability mass function for X by

fX(x) = P(X = x)

X is discrete if it takes countably many values {x1, x2, …}.
Here, fX(x) ≥ 0 for all x ∈ R and ifX(xi) = 1.
The CDF of X is related to fX by


We will use fX and FX simply as f and F. Try writing and plotting probability function for flipping a coin experiment whose CDF is shown in previous section.


Probability density function (For Continuous R.V.)

A random variable X is continuous if there exists a function fX such that fX(x) ≥ 0 for all x, and for every a ≤ b,

pdf_2

The function fX is called the probability density function (PDF). We have that

pdf_3

and fX(x) = F’X (x) at all points x at which FX is differentiable.

Suppose that X has a PDF
pdf-example
clearly fX(x) ≥ 0 and ∫fX(x)dx = 1.
A random variable with this density is said to have Uniform (0,1) distribution. The CDF is given by
pdf-example2

cdf uniform
CDF for Uniform (0, 1)

2 Comments

    Leave A Comment