3.1  Random Variables
3.1  Random VariablesWhat is a random variable?
Let's use a scenario to introduce the idea of a random variable.
Suppose we flip a fair coin three times and record if it shows a head or a tail. The outcome or sample space is S={HHH,HHT,HTH,THH,TTT,TTH,THT,HTT}. There are eight possible outcomes and each of the outcomes is equally likely. Now, suppose we flipped a fair coin four times. How many possible outcomes are there? There are $2^4 = 16$. How about ten times? $1024$ possible outcomes! Instead of considering all the possible outcomes, we can consider assigning the variable $X$, say, to be the number of heads in $n$ flips of a fair coin. If we flipped the coin $n=3$ times (as above), then $X$ can take on possible values of \(0, 1, 2,\) or \(3\). By defining the variable, \(X\), as we have, we created a random variable.
 Random Variable

A random variable is a variable that takes on different values determined by chance.
Types of Random Variables
There are two types of random variables, qualitative (or categorical) and quantitative.
 Qualitative Random Variables
 The possible values vary in kind but not in numerical degree. They are also called categorical variables.
 Quantitative Random Variables
 There are two types of quantitative random variables.
 Discrete Random Variable: When the random variable can assume only a countable, sometimes infinite, number of values.
 Continuous Random Variable: When the random variable can assume an uncountable number of values in a line interval.
Probability Functions
Transforming the outcomes to a random variable allows us to quantify the outcomes and determine certain characteristics. If we have a random variable, we can find itâ€™s probability function.
 Probability Function

A probability function is a mathematical function that provides probabilities for the possible outcomes of the random variable, \(X\). It is typically denoted as \(f(x)\).
There are two classes of probability functions: Probability Mass Functions and Probability Density Functions.
 Probability Mass Function (PMF)

If the random variable is a discrete random variable, the probability function is usually called the probability mass function (PMF). If X is discrete, then \(f(x)=P(X=x)\). In other words, the PMF for a constant, \(x\), is the probability that the random variable \(X\) is equal to \(x\). The PMF can be in the form of an equation or it can be in the form of a table.

Properties of probability mass functions:
 \(f(x)>0\), for x in the sample space and 0 otherwise.
 \(\sum_x f(x)=1\). In other words, the sum of all the probabilities of all the possible outcomes of an experiment is equal to 1.

 Probability Density Function (PDF)

If the random variable is a continuous random variable, the probability function is usually called the probability density function (PDF). Contrary to the discrete case, $f(x)\ne P(X=x)$

Properties of a probability density function:
 \(f(x)>0\), for x in the sample space and 0 otherwise.
 The area under the curve is equal to 1.

The probability of a random variable being less than or equal to a given value is calculated using another probability function called the cumulative distribution function.
 Cumulative Distribution Function (CDF)

A cumulative distribution function (CDF), usually denoted $F(x)$, is a function that gives the probability that the random variable, X, is less than or equal to the value x.

\(F(x)=P(X\le x)\)

Note! The definition of the cumulative distribution function is the same for a discrete random variable or a continuous random variable. For a continuous random variable, however, \(P(X=x)=0\). Therefore, the CDF, \(F(x)=P(X\le x)=P(X<x)\), for the continuous case.
