Functions and pairs of random variables

Functions of random variables

When a signal generated under a certain probability distribution is manipulated, the probability distribution that follows from this transformation is usually difficult to determine; however, the expected value and variance are usually easier to compute.

Linear combinations of random variables

One common category of these transformation consists of the linear combinations of a continuous random variable X, with mean μX and variance σX2. Suppose that the random variable Y is a linear combination of X defined by (1)Y=aX+b, with a and b deterministic constants. The mean of the random variable Y can be determined as (2)E[Y]=E[aX+b]=(ax+b)pX(x)dx=axpX(x)dx+bpX(x)dx=aE[X]+b=aμX+b From this we have now obtained the rules that allowed us to rewrite the variance in an earlier subsection. Similarly the variance of Y can be determined using the previous result as (3)Var[Y]=E[(YμY)2]=E[(aX+b(aμX+b))2]=E[a2(XμX)2]=a2(xμX)2pX(x)dx=a2(xμX)2pX(x)dx=a2Var[X] A very similar derivation also holds for discrete random variables. Please note that the constant b did not have an effect on the variance of Y. Intuitively this makes sense since the variance is a measure of the spread of a variable. By adding a constant the spread of the probability distribution will not change.

Continuous elementary functions

Sometimes it can be useful to define probability distributions in the continuous domain more flexibly. Up until now we were limited by the given families of distributions, but one might for example want to alter these distributions slightly according to the situation. Suppose there is a random variable X that behaves as a uniform distribution for X<0 and an exponential distribution for X0. How can we describe this distribution mathematically? For this the delta pulse function and the unit step function need to be introduced.

Dirac delta pulse function

The Dirac delta pulse function is a function that only exists for one single value on its domain. The value at this point is undefined, but it guarantees that the integral over its domain equals 1. The dirac delta pulse is therefore defined as (4)δ(x)={+,for x=00,for x0 under the constraint (5)δ(x)dx=00+δ(x)dx=1, where 0 and 0+ are the limits towards 0 from below and above respectively.

Shifting property

The definition of the Dirac delta pulse function allows us to extract values from a function by simply multiplying with the delta pulse and integrating over the domain. This delta pulse can be shifted on its domain, allowing for the extraction at any point on the function. This process can be regarded as sampling. This is known as the sifting property and is defined as (6)g(x)δ(xx0)dx=x0x0+g(x)δ(xx0)dx=g(x0).

Discrete to continuous probability functions

With the introduction of the Dirac delta pulse, we are now also capable of transforming a discrete probability mass function into a continuous probability density distribution. Each of the values of the probability mass function can be represented as a delta pulse multiplied with the corresponding value. As an example, the probability mass function of the discrete Bernoulli(p) distribution can be written as a probability density function as (7)pX(x)=(1p)δ(x)+pδ(x1). Similarly all other discrete probability mass functions can be rewritten as continuous probability density functions. For more details about the Bernoulli distribution, check the section Families of random variables.

Unit step function

It is also possible that a probability density function is zero up to a threshold x0, after which it nicely follows a known distribution pX(x). The mathematical description of this piece-wise probability density function can be determined using the unit step function, which is defined as (8)u(x)={1,for x00.for x<0 This function allows us to put a known probability density function pX(x) to zero up to a certain threshold x0, whilst retaining the other part of the function. A generalization of such a new probability density function pX1(x) can be written as (9)pX1(x)=cpX(x)u(xx0), where c is a constant that is required to satisfy the total probability axiom (pX1(x)dx=1).

Mixed random variables

When the probability density function of a random variable consists of a combination of both delta pulses and probability density functions, it can be regarded as a mixed random variable. An example of a random variable is given in the following example. The definition of mixed random variable is

X is a mixed random variable if and only if pX(x) consists of both impulses and non-zero, finite values.

Example

Suppose we are monitoring the duration of phone calls. The measured duration x in minutes can be regarded as a continuous random variable X, which is distributed as an exponential random variable with rate parameter λ=1. This can be written as XExp(λ=1) with probability density function (10)pX(x)={ex,for x00.for x<0 The service provider decides for simplicity to round all phone calls lasting less than 60 seconds to exactly 1 minute. This administrative duration y in minutes can be represented by a mixed random variable Y. The administrative duration can be mathematically determined as (11)y={1,for x<1x.for x1 Let us now derive the probability density function of Y. In order to do so, the derivation is split for the cases Y<1, Y=1 and Y>1.

We can easily see that pY(y)=0 for y<1, because the duration is always rounded to at least 1 minute.

For Y=1 a true probability is involved, since there is a non-zero probability that the administrative duration is exactly 1 minute. Because the integral of the probability density function should return a non-zero value at y=1 when integrating 11+pY(y)dy, a Dirac delta pulse should be located at y=1 in order to make sure that the integral returns the true probability. This delta pulse should be multiplied with the probability of the occurrence of this event. This probability can be determined as (12)Pr[Y=1]=Pr[X<1]=1pX(x)dx=01exdx=[ex]01=1e1. For Y>1 the probability density function of Y simply follows the exponential distribution of X. In order to cope with this partial domain, pX(x) needs to be multiplied with the shifted unit step function.

So to conclude the probability density function of Y can be written as (13)pY(y)=(1e1)δ(y1)+eyu(y1).



Pairs of random variables

So far this module has only focused on events that produce a single outcome and therefore can only have a single random variable. However, it is also possible for an event to return multiple random variables.

Screencast video [⯈]



Example

Suppose we have an experiment in which we throw 2 dice consecutively and we collect the total amount of eyes after the first and second dice are thrown. Assuming normal dice, the total amount of eyes observed after the first throw should be an integer between 1 and 6. But how can we now describe the total amount of eyes after throwing the second dice? It will be clear that this second observation will be between 2 and 12 eyes. However, we do need to keep in mind that the second observation depends greatly on the first observation. It is for example impossible to first observe a total of 5 eyes after throwing the first dice and then to observe a total of 4 eyes after throwing the second dice.

Joint random variables

Through the previous example it is clear that there is a need to combine multiple random variables into a single function in order to draw conclusions about observations and their probabilities. Multiple random variables that are all associated with an event are called joint random variables. These random variables are usually denoted with different capital letters (e.g. X and Y). The theory that follows, holds for every number of joint random variables, however, for simplicity this reader will only discuss random processes described by 2 joint random variables.

Joint cumulative distribution function

In order to describe the probabilities that are associated with the observations (x, y), we will introduce the joint cumulative distribution function, which is a variant of the cumulative distribution function. This joint cumulative distribution function is defined for the random variables X and Y as (14)PX,Y(x,y)=Pr[Xx,Yy], where the comma in the probability operator indicates that both conditions need to hold.

Joint probability axioms

Similarly to the single random variable case, axioms can be determined for the joint cumulative distribution function. These axioms include

  1. It holds that 0PX,Y(x,y)1.
  2. It holds that PX,Y(,)=1 and that PX,Y(x,)=PX,Y(,y)=0.
  3. It holds that PX(x)=PX,Y(x,) and similarly PY(y)=PX,Y(,y).
  4. The function is non-decreasing (i.e. for xx0 and yy0 it holds PX,Y(x,y)PX,Y(x0,y0)).
The first axiom is a consequence of the total probability axiom, where a probability cannot be negative nor larger than 1.

A total probability of 1 only occurs when both Xx and Yy are always satisfied, which is the case for PX,Y(,). Similarly, there is by definition no event where x or y and therefore this (cumulative) probability is always 0.

When one of the conditions Xx and Yy is always satisfied, the cumulative distribution does not depend on that variable anymore and therefore that variable can be removed from the equation, leaving a distribution that now depends on one single random variable. This process is called marginalization and will be discussed later on.

Finally as seen previously the cumulative distribution is a sum or integral over an ever-increasing domain with non-negative values, leading to a non-decreasing function.

Joint probability density function

The previous definition of the joint cumulative distribution function both holds for continuous as discrete random variables. For the continuous random variables the joint probability density function can be defined through the relationship (15)xypX,Y(u,v) du dv=PX,Y(x,y) and can be calculated from the joint cumulative distribution function as (16)pX,Y(x,y)=2PX,Y(x,y)xy.

Joint probability mass function

In the case of discrete random variables, the joint probability mass function can be defined explicitly as (17)pX,Y(x,y)=Pr[X=x,Y=y], because the values that the function returns are true probabilities.

Expected value

The expected value of the joint random variables can be determined similarly to the single variable case. Given a new random variable W, which is an arbitrary function of the random variable X and Y through W=g(X,Y), the expected value of W can be determined as (18)E[W]=xSXySYg(x,y)pX,Y(x,y) in the case of discrete random variables and as (19)E[W]=g(x,y)pX,Y(x,y) dx dy in the case of continuous random variables.

Marginalization

In many engineering problems you are only interested in the outcome of one random variable. When a joint probability function is available it is possible to marginalize over all other random variables except for the one random variable in which you are interested, leaving you with the probability function of just that random variable. This marginalization is performed for discrete random variables through (20)pX(x)=ySYpX,Y(x,y) and for continuous random variables through (21)pX(x)=pX,Y(x,y)dy. This operation can be understood when viewing the summation or integration as “taking all possibilities of all other random variables into account”. The proof for the continuous random variables follows (22)pX(x)=PX(x)x,=xPr[Xx],=xPr[Xx,Y],=xx(pX,Y(v,u)du)dv,=pX,Y(u,v)dv. A similar proof can be found for the marginalization of discrete random variables.

Conditional probabilities

When considering events with multiple outcomes we might be able to deduce one outcome from another. Take the example of the two dice. If we know that the first die rolls 5 eyes then we automatically know that the total amount of eyes after the second throw is 6 up to 11 with equal probability. Similarly we may deduce with 100% certainty that the first throw should have given 6 eyes, when 12 eyes are observed after the second throw.

This line of reasoning is an example of conditional probability. Conditional probability involves the probability of some event when another event is observed. In the reader on probability theory, the definition of conditional probability was given and explained. If this definition is combined with random variables, two separate cases can be identified.

First, it is possible to determine the conditional probability function, which is the probability mass function or probability density function of observing outcomes (x,y), when it is known that the outcomes can be found somewhere in an event set B, which is a subset of the sample space S. When the initial joint probability function is given by pX,Y(x,y), the conditional probability function of X and Y given B (i.e. X,Y|B) can be determined as (23)pX,Y|B(x,y)={pX,Y(x,y)Pr[B],when (x,y)B0.otherwise This operation can be regarded as assigning all outcomes outside set B to zero and normalizing the remaining function to satisfy the total probability axiom.

Secondly it is also possible that one outcome is observed and we would like to find the probability function of the other random variables. Let us now suppose that the random variable Y is observed as y and we are interested in finding the conditional probability function of X, which is pX|Y(x|y). For discrete random variables this conditional probability mass function can be determined as (24)pX|Y(x|y)=Pr[X=x|Y=y]=Pr[X=x,Y=y]Pr[Y=y]=pX,Y(x,y)pY(y). Keep in mind that the marginalized probability mass function pY(y) can be calculated using marginalization. Similarly to the derivation for the discrete random variables, the conditional probability density function of continuous random variables can be determined as (25)pX|Y(x|y)=pX,Y(x,y)pY(y)=pX,Y(x,y)pX,Y(x,y)dx

Example

Suppose we are given the joint probability density function (26)pX,Y(x,y)={Cex,for x0 and xyx0,otherwise where C is a constant to be determined. Let us now derive the value of C, the marginal probability density functions pX(x) and pY(y) and the conditional probability density function pY|X(y|x).

In order to calculate C we need to make use of the total probability axiom, which is given as (27)pX,Y(x,y) dx dy=1 for the joint random variables case. If we substitute the given joint probability density function with the given constraints we find (28)0xxCex dy dx=C0exxx1 dy dx=C0ex[y]xx dx,=2C0xex dx=12C[xex]02C0exdx,=2C[xex]02C[ex]0,=22C(00)2C(01)=2C=1. From this follows that C=12.

12

In order to calculate pX(x) we will marginalize pX,Y(x,y) over Y as (29)pX,Y(x,y)dy=xxCexdy=Cexxx1dy=2Cxex. When substituting the value of C and considering that the function only exists for x0, the marginal probability density function can be determined as (30)pX(x)={xex,for x00.otherwise

Similarly we can find the marginal probability density function pY(y). One might say that the marginalization integral has a lower-bound for x, namely x0. However, this is not entirely correct. When rewriting the constraint xyx as x|y| it becomes clear that x is not bounded by 0, but by |y|. The marginal probability density function is not bounded on y by a constant and can therefore be written as (31)pY(y)=|y|Cexdx=C[ex]|y|=C(0+e|y|)=12e|y|.

Now finally we can use our previous results in order to determine the conditional probability density function as (32)pY|X(y|x)=pX,Y(x,y)pX(x)={12exxex,for x0 and xyx0,otherwise={12x,for x0 and xyx0.otherwise One could apply the axiom of total probability to all marginalized and conditional probability density functions over their domain and should note that the axiom is satisfied.



Exercise


Random variables X and Y have joint PDF fX,Y(x,y)={5x2/21x1;0yx2,0otherwise. Answer the following questions:
  1. What are E[X] and Var[X]?
  2. What are E[Y] and Var[Y]?
  3. What is E[X+Y]?
  1. The first moment of X is E[X]=110x2x5x22dydx=115x52dx=5x612|11=0. Since E[X]=0, the variance of X and the second moment are both Var[X]=E[X2]=110x2x25x22dydx=5x714|11=1014.
  2. The first and second moments of Y are E[Y]=110x2y5x22dydx=514, E[Y2]=110x2y25x22dydx=527. Therefore, Var[Y]=5/27(5/14)2=.0576.
  3. The expected value of the sum X+Y is E[X+Y]=E[X]+E[Y]=514.

Central limit theorem

Screencast video [⯈]



We have briefly discussed what happens with the signal statistics, especially the mean and variance, when a random variable is linearly transformed. Now let us focus on the specific situation where we take the sum of N independent continuous random variables. We will define a random variable Y as (33)Y=X1+X2++XNN and have a look at what the probability density function of Y looks like.

In Fig. 1, 100000 samples are generated from three different probability distributions and the resulting histograms are plotted. This is repeated for an increasing number N, and the histograms are plotted after averaging N similarly generated sets of data. It can be noted that after averaging multiple realizations of a random variable generated from the same (arbitrary) distribution, the distribution of the averaged random variables converges to a Gaussian distribution. This result is known as the central limit theorem (CLT).

Visualisation of the central limit theorem.
Demonstration of the CLT for three different probability distributions, i.e. U(0,5), U(10,10) and Exp(λ=1), where N sets of 100000 realizations are averaged and the new distributions of the averaged 100000 samples are shown for different values of N. A Gaussian function is fitted over the distributions and it can be seen that after averaging over more realizations, the new distribution will converge to the Gaussian distribution.

The formal definition is given as:

Let X1,X2,,Xn be a set of N independent identically-distributed (i.i.d) random variables and each Xi has an arbitrary probability distribution p(x1,x2,,xn) with finite mean μi=μ and finite standard deviation σi=σ. If the sample size N is “sufficiently large”, then the CDF of the sum converges to a Gaussian CDF.

In simple words, the CLT states that the normalized sum of a sufficient number of i.i.d. random variables tends to a Gaussian distribution. It is also possible to predict the mean and the variance of the Gaussian probability density function after a sufficiently large set of N random variables has been summed. The minimum value of N for the CLT approximation to be valid depends on the distribution of the individual random variables.

Under certain conditions, the CLT can be extended for the sum of random variables that are independent but not necessarily identically distributed (i.e., Lyapunov condition). In both cases, the mean or expected value of the approximate Gaussian probability density function can be determined as (34)E[Y]=1Ni=1NE[Xi], which is simply the average value of all individual expected values. Similarly the variance can be determined as (35)Var[Y]=σY2=1N2i=1NσXi2=1N2i=1NVar[Xi].

Similarly the random variable Z, which is the sum over normalized random variables, can be defined as (36)Z=1Ni=1NXiE[Xi]σXi. Through the central limit theorem it follows that the probability density function of the random variable Z converges to the normalized Gaussian distribution N(0,1).


  1. Integration by parts: abf(x)g(x)dx=[f(x)g(x)]ababf(x)g(x)dx ↩︎

  2. Growth property of exponentials: limxxaex=0 ↩︎