Discrete Random Variables

Introduction

A discrete random variable XX is a function from the sample space SS to a set of possible values RR.

X:SRX: S \rightarrow R

Each of those possible values has a probability of occurring depending on the mappings from the sample space.

Probability mass function

This is the function that determines the probability of a discrete random variable XX having a certain value. The equation used to calculate this value will differ depending on the type of random variable.

p(x)=P(X=k)p(x) = \Bbb{P}(X = k)

This can also be used to determine the distribution of probabilities for each possible value of XX.

Probability mass function

Expected value

In any given situation, we are able to calculate the value of a discrete random variable XX that is expected. This value is like a weighted average.

It is given by the equation below:

E[X]=k=0nkP(X=k)\Bbb{E}[X] = \displaystyle\sum\limits_{k=0}^{n} k\Bbb{P}(X = k)

It is important to note that the above will change depending on the type of random variable you are working with. In other words, be careful when expanding P(X=k)\Bbb{P}(X = k).

There is also a case where we can be asked to find the expected value of a function of XX:

E[g(X)]=k=0ng(k)P(X=k)\Bbb{E}[g(X)] = \displaystyle\sum\limits_{k=0}^{n} g(k)\Bbb{P}(X = k)

A moment of a discrete random variable is the expected value of a given power of XX. The nthn^{th} moment of a discrete random variable is defined as:

E[Xn]=k=0nknP(X=k)\Bbb{E}[X^n] = \displaystyle\sum\limits_{k=0}^{n} k^n \Bbb{P}(X = k)

Stirling’s approximation

This is a method of approximating factorials:

k!(ke)k2πkk! \backsim \bigg(\dfrac{k}{e}\bigg)^k \sqrt{2 \pi k}

Where the \backsim symbol means that the ratio of the two quantities tends to 1 as kk tends to infinity.

limkk!(ke)k2πk=1\displaystyle\lim_{k \to \infty} \dfrac{k!}{\bigg(\dfrac{k}{e}\bigg)^k \sqrt{2 \pi k}} = 1

Joint distributions

So far we have examined cases with the possible values of one random variable. Now we need to think about what to do when we want to know the probability of two random variables having certain values.

P(X=k,Y=j)\Bbb{P}(X = k, Y = j)

If these two random variables are independent then:

P(X=k,Y=j)=P(X=k)P(Y=j)\Bbb{P}(X = k, Y = j) = \Bbb{P}(X = k) \Bbb{P}(Y = j)

Otherwise, we need to look at the marginal distributions which are essentially the probability mass function of each value of a random variable laid out in a table.

For example, let’s take a case where we have 2 red pens, 1 green pen and 1 blue pen. Two pens are picked at random without replacement. Let XX be the number of red pens chosen and YY be the number of green pens chosen. We can calculate the marginal distributions as:

Marginal distributions

These can then be joined into a joint distribution table:

Joint distributions

Some properties of joint distributions include:

  • E[aX+bY]=aE[X]+bE[Y]\Bbb{E}[aX + bY] = a\Bbb{E}[X] + b\Bbb{E}[Y]

  • Var[X+Y]=Var[X]+Var[Y]+2Cov[X,Y]Var[X + Y] = Var[X] + Var[Y] + 2Cov[X,Y]

  • E[XY]=XYx,y,p(x,y)\Bbb{E}[XY] = \displaystyle\sum_X \displaystyle\sum_Y x \\, y \\, p(x,y)
    Sum of the product of x,y,p for each element in the joint table.

You can also use the following to calculate joint distribution table values:

P(X=x,Y=y)=P(X=xY=y)P(Y=y)\Bbb{P}(X = x, Y = y) = \Bbb{P}(X = x | Y = y) \Bbb{P}(Y = y)

This works both ways:

P(X=xY=y)=P(X=x,Y=y)P(Y=y)\Bbb{P}(X = x | Y = y) = \dfrac{\Bbb{P}(X = x, Y = y)}{\Bbb{P}(Y = y)}

Variance & covariance

The variance of a discrete random variable XX is a number which defines how much the possible values of XX differ from each other. It can be calculated using:

Var[X]=E[(XE[X])2]=E[X2]E[X]2\begin{aligned} Var[X] &= \Bbb{E}[(X - \Bbb{E}[X])^2] \\\\ &= \Bbb{E}[X^2] - \Bbb{E}[X]^2 \end{aligned}

The covariance, on the other hand, determines how much the possible values of two random variables XX and YY differ from each other. It can be calculated using:

Cov[X,Y]=E[(XE[X])(YE[Y])]=E[XY]E[X]E[Y]\begin{aligned} Cov[X,Y] &= \Bbb{E}[(X - \Bbb{E}[X])(Y - \Bbb{E}[Y])] \\\\ &= \Bbb{E}[XY] - \Bbb{E}[X]\Bbb{E}[Y] \end{aligned}

As a side note, the standard deviation can be calculated by:

SD(X)=Var[X]SD(X) = \sqrt{Var[X]}

Independent variables

By definition, two random variables X,YX, Y are independent if:

P(X=xk,Y=yj)=P(X=xk)P(Y=yj)\Bbb{P}(X = x_k, Y = y_j) = \Bbb{P}(X = x_k) \Bbb{P}(Y = y_j)

An implication of this, using the equivalencies in the section above, is:

IndependenceCov[X,Y]=0\text{Independence} \Rightarrow Cov[X,Y] = 0

However, be aware that this statement only works in one logical direction. Covariance being zero does not implicate anything. You can prove that two random variables are not independent if:

Cov[X,Y]=Cov[X,Y] = \not 0