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:

HH1/4 2

xP(X = x)

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.

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

X is discrete if it takes countably many values {x1, x2, …}
We define the probability function or probability mass function for X by

fX(x) = P(X = x)

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

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,


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


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

Suppose that X has a PDF
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

cdf uniform
CDF for Uniform (0, 1)


    Leave A Comment