Search for probability and statistics terms on Statlect
StatLect

Random variable

by , PhD

A random variable is a variable whose value depends on the outcome of a probabilistic experiment. Its value is a priori unknown, but it becomes known once the outcome of the experiment is realized.

Table of Contents

Definition

Denote by Omega the set of all possible outcomes of a probabilistic experiment, called a sample space.

A random variable associates a real number to each element of Omega, as stated by the following definition.

Definition A random variable X is a function from the sample space Omega to the set of real numbers R:[eq1]

In rigorous (measure-theoretic) probability theory, the function X is also required to be measurable (see a more rigorous definition of random variable).

The real number [eq2] associated to a sample point omega in Omega is called a realization of the random variable.

The set of all possible realizations is called support and is denoted by R_X.

Example

This example shows how the realizations of a random variable are associated with the outcomes of a probabilistic experiment.

Suppose that we flip a coin. The possible outcomes are either tail ($T$) or head (H), that is,[eq3]

The two outcomes are assigned equal probabilities:[eq4]

If tail ($T$) is the outcome, we win one dollar, if head (H) is the outcome we lose one dollar.

The amount X we win (or lose) is a random variable, defined as follows:[eq5]

The probability of winning one dollar is[eq6]

The probability of losing one dollar is[eq7]

The probability of losing two dollars is[eq8]

Notation

Some remarks on notation are in order:

  1. The dependence of X on omega is often omitted, that is, we simply write X instead of [eq9].

  2. If [eq10], the exact meaning of the notation [eq11] is the following:[eq12]

  3. If [eq10], we sometimes use the notation [eq14] with the following meaning:[eq15]In this case, $QTR{rm}{P}_{X}$ is to be interpreted as a probability measure on the set of real numbers, induced by the random variable X. Often, statisticians construct probabilistic models where a random variable X is defined by directly specifying $QTR{rm}{P}_{X}$, without specifying the sample space Omega.

Types of random variables

Most of the time, statisticians deal with two special kinds of random variables:

  1. discrete random variables;

  2. continuous random variables.

These two types are described in the next sections.

Discrete random variables

Here is the first kind.

Definition A random variable X is discrete if

  1. its support R_X is a countable set;

  2. there is a function [eq16], called the probability mass function (or pmf or probability function) of X, such that, for any $xin U{211d} $:[eq17]

The following is an example of a discrete random variable.

Example A Bernoulli random variable is an example of a discrete random variable. It can take only two values: 1 with probability $q$ and 0 with probability $1-q$, where [eq18]. Its support is [eq19]. Its probability mass function is[eq20]

Probability mass functions are characterized by two fundamental properties.

  1. Non-negativity: [eq21] for any $xin U{211d} $;

  2. Sum over the support equals 1: [eq22].

Any probability mass function must satisfy these two properties.

Moreover, any function satisfying these two properties is a legitimate probability mass function.

These and other properties of probability mass functions are discussed more in detail in the lecture on Legitimate probability mass functions.

Continuous random variables

Continuous variables are defined as follows.

Definition A random variable X is continuous (or absolutely continuous) if and only if

  1. its support R_X is not countable;

  2. there is a function [eq23], called the probability density function (or pdf or density function) of X, such that, for any interval [eq24]:[eq25]

The page on the probability density function explains why we need integrals to deal with continuous variables.

We now illustrate the definition with an example.

Example A uniform random variable (on the interval $left[ 0,1
ight] $) is an example of a continuous variable. It can take any value in the interval $left[ 0,1
ight] $. All sub-intervals of equal length are equally likely. Its support is [eq26]. Its probability density function is[eq27]The probability that the realization of X belongs, for example, to the interval [eq28] is[eq29]

Probability density functions are characterized by two fundamental properties:

  1. Non-negativity: [eq30] for any $xin U{211d} $;

  2. Integral over R equals 1: [eq31].

Any probability density function must satisfy these two properties.

Moreover, any function satisfying these two properties is a legitimate probability density function.

The lecture on Legitimate probability density functions contains a detailed discussion of these facts.

Random variables in general

Random variables, also those that are neither discrete nor continuous, are often characterized in terms of their distribution function.

Definition Let X be a random variable. The distribution function (or cumulative distribution function or cdf ) of X is a function [eq32] such that[eq33]

If we know the distribution function of a random variable X, then we can easily compute the probability that X belongs to an interval [eq34] as[eq35]

Proof

Note that[eq36]where the two sets on the right hand side are disjoint. Hence, by additivity:[eq37]By rearranging terms, we get[eq35]

Want to learn more about the cdf? Check here.

More details

In the following subsections you can find more details on random variables and univariate probability distributions.

Derivative of the distribution function of a continuous variable

Note that, if X is continuous, then[eq39]

Hence, by taking the derivative with respect to x of both sides of the above equation, we obtain[eq40]

Continuous random variables and zero-probability events

Note that, if X is a continuous random variable, the probability that X takes on any specific value $xin R_{X}$ is equal to zero:[eq41]

Thus, the event [eq42] is a zero-probability event for any $xin R_{X}$.

The lecture on Zero-probability events contains a thorough discussion of this apparently paradoxical fact: although it can happen that [eq43], the event [eq44] has zero probability of happening.

A more rigorous definition of random variable

Random variables can be defined in a more rigorous manner by using the terminology of measure theory, and in particular the concepts of sigma-algebra, measurable set and probability space introduced at the end of the lecture on probability.

Definition Let [eq45] be a probability space, where Omega is a sample space, [eq46] is a sigma-algebra of events (subsets of Omega) and $QTR{rm}{P}$ is a probability measure on [eq47]. Let [eq48] be the Borel sigma-algebra of the set of real numbers R (i.e., the smallest sigma-algebra containing all the open subsets of R). A function [eq49] such that [eq50]for any [eq51] is said to be a random variable on Omega.

This definition ensures that the probability that the realization of the random variable X will belong to a set [eq51] can be defined as [eq53]where the probability on the right-hand side is well defined because the set [eq54] is measurable.

One question remains to be answered: why did we introduce the exotic concept of Borel sigma-algebra?

Clearly, if we want to assign probabilities to subsets of R (to which the realizations of the random variable X could belong), then we need to define a sigma-algebra of subsets of R (remember that we need a sigma-algebra in order to define probability rigorously).

But why can't we consider the simpler to understand set of all possible subsets of R, which is a sigma-algebra?

The short answer is that we are not able to define a probability measure on sigma-algebras larger (i.e., containing more subsets of R) than the Borel sigma-algebra: whenever we try to do so, we end up finding some uncountable sets for which the sigma-additivity property of probability does not hold (i.e., their probability is different from the sum of the probabilities of their parts) or such that their probability is not equal to one minus the probability of their complements.

Solved exercises

Below you can find some exercises with explained solutions.

Exercise 1

Let X be a discrete random variable. Let its support R_X be[eq55]

Let its probability mass function [eq56] be[eq57]

Calculate the following probability:[eq58]

Solution

By the additivity of probability, we have that[eq59]

Exercise 2

Let X be a discrete random variable. Let its support R_X be the set of the first $20$ natural numbers:[eq60]

Let its probability mass function [eq56] be[eq62]

Compute the probability[eq63]

Solution

By using the additivity of probability, we obtain[eq64]

Exercise 3

Let X be a discrete random variable. Let its support R_X be[eq65]

Let its probability mass function [eq56] be[eq67]where [eq68] is the binomial coefficient.

Calculate the probability[eq69]

Solution

First note that, by additivity:[eq70]

Therefore, in order to compute [eq71], we need to evaluate the probability mass function at the three points $x=0,$, $x=1$ and $x=2$:[eq72]

Finally,[eq73]

Exercise 4

Let X be a continuous random variable. Let its support R_X be[eq74]

Let its probability density function [eq75] be[eq76]

Compute[eq77]

Solution

The probability that a continuous variable takes a value in a given interval is equal to the integral of the probability density function over that interval:[eq78]

Exercise 5

Let X be a continuous variable. Let its support R_X be[eq79]

Let its probability density function [eq75] be[eq81]

Compute[eq82]

Solution

As in the previous exercise, the probability that X takes a value in a given interval is equal to the integral of its density function over that interval:[eq83]

Exercise 6

Let X be a continuous variable. Let its support R_X be[eq84]

Let its probability density function [eq75] be[eq86]where $lambda >0$.

Compute[eq87]

Solution

As in the previous exercise, we need to compute an integral:[eq88]

More exercises

Looking for more exercises? Try StatLect's probability exercises page.

How to cite

Please cite as:

Taboga, Marco (2021). "Random variable", Lectures on probability theory and mathematical statistics. Kindle Direct Publishing. Online appendix. https://www.statlect.com/fundamentals-of-probability/random-variables.

The books

Most of the learning materials found on this website are now available in a traditional textbook format.