# Introduction to Random Variables

## Random Variable

A

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

ω | P({ω}) | X(ω) |

TT | 1/4 | 0 |

TH | 1/4 | 1 |

HT | 1/4 | 1 |

HH | 1/4 | 2 |

x | P(X = x) |

0 | 1/4 |

1 | 1/2 |

2 | 1/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

F_{X}: R→[0,1] defined by

F_{X}(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.

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. x_{1} < x_{2} implies that F(x_{1}) ≤ F(x_{2}).

(ii) F is normalized: lim _{x→-∞}F(x) = 0 and lim_{x→∞}F(x) = 1.

(iii) F is right-continuous, i.e. F(x) = F(x^{+}) for all x, where

F(x^{+}) = lim_{y→x, y>x} F(y)

### Probability Function or Probability Mass Function

X is discrete if it takes countably many values {x

_{1}, x_{2}, …}

We define the probability function or probability mass function for X byf

_{X}(x) = P(X = x)

Here, **f _{X}(x) ≥ 0** for all x ∈ R and

**∑**. The CDF of X is related to f

_{i}f_{X}(x_{i}) = 1_{X}by

We will use f_{X} and F_{X} 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 f_{X}such that f_{X}(x) ≥ 0 for all x,and for every a ≤ b,

The function f_{X}is called the probability density function (PDF). We have thatand

f_{X}(x) = F’_{X}(x) at all points x at which F_{X}is differentiable.

Suppose that X has a PDF

clearly f_{X}(x) ≥ 0 and f_{X}(x)dx = 1. A random variable with this density is said to have Uniform (0,1) distribution. The CDF is given by