# Algebra of random variables

The algebra of random variables provides rules for the symbolic manipulation of random variables, while avoiding delving too deeply into the mathematically sophisticated ideas of probability theory. Its symbolism allows the treatment of sums, products, ratios and general functions of random variables, as well as dealing with operations such as finding the probability distributions and the expectations (or expected values), variances and covariances of such combinations. In principle, the elementary algebra of random variables is equivalent to that of conventional non-random (or deterministic) variables. However, the changes occurring on the probability distribution of a random variable obtained after performing algebraic operations are not straightfoward. Therefore, the behavior of the different operators of the probability distribution, such as expected values, variances, covariances, and moments, may be different from that observed for the random variable using symbolic algebra. It is possible to identify some key rules for each of those operators, resulting in different types of algebra for random variables, apart from the elementary symbolic algebra: Expectation algebra, Variance algebra, Covariance algebra, Moment algebra, etc.

## Elementary symbolic algebra of random variables

Considering two random variables ${\displaystyle X}$  and ${\displaystyle Y}$ , the following algebraic operations are possible:

• Addition: ${\displaystyle Z=X+Y=Y+X}$
• Subtraction: ${\displaystyle Z=X-Y=-Y+X}$
• Multiplication: ${\displaystyle Z=XY=YX}$
• Division: ${\displaystyle Z=X/Y=X\cdot (1/Y)=(1/Y)\cdot X}$
• Exponentiation: ${\displaystyle Z=X^{Y}=e^{Y\ln(X)}}$

In all cases, the variable ${\displaystyle Z}$  resulting from each operation is also a random variable. All commutative and associative properties of conventional algebraic operations are also valid for random variables. If any of the random variables is replaced by a deterministic variable or by a constant value, all the previous properties remain valid.

## Expectation algebra for random variables

The expected value ( ${\displaystyle E}$ ) of the random variable ${\displaystyle Z}$ resulting from an algebraic operation between random variables can be calculated using the following set of rules:

• Addition: ${\displaystyle E[Z]=E[X+Y]=E[X]+E[Y]=E[Y]+E[X]}$
• Subtraction: ${\displaystyle E[Z]=E[X-Y]=E[X]-E[Y]=-E[Y]+E[X]}$
• Multiplication: ${\displaystyle E[Z]=E[XY]=E[YX]}$ . Particularly, if ${\displaystyle X}$ and ${\displaystyle Y}$ are independent from each other, then: ${\displaystyle E[XY]=E[X]\cdot E[Y]=E[Y]\cdot E[X]}$ .
• Division: ${\displaystyle E[Z]=E[X/Y]=E[X\cdot (1/Y)]=E[(1/Y)\cdot X]}$ . Particularly, if ${\displaystyle X}$ and ${\displaystyle Y}$ are independent from each other, then: ${\displaystyle E[X/Y]=E[X]\cdot E[1/Y]=E[1/Y]\cdot E[X]}$ .
• Exponentiation: ${\displaystyle E[Z]=E[X^{Y}]=E[e^{Y\ln(X)}]}$

If any of the random variables is replaced by a deterministic variable or by a constant value ( ${\displaystyle k}$ ), the previous properties remain valid considering that ${\displaystyle E[k]=k}$ .

If ${\displaystyle Z}$ is defined as a general non-linear algebraic function ${\displaystyle f}$ of a random variable ${\displaystyle X}$ , then:

${\displaystyle E[Z]=E[f(X)]\neq f(E[X])}$

Some examples of this property include:

• ${\displaystyle E[X^{2}]\neq (E[X])^{2}}$
• ${\displaystyle E[1/X]\neq 1/E[X]}$
• ${\displaystyle E[e^{X}]\neq e^{E[X]}}$
• ${\displaystyle E[\ln(X)]\neq \ln(E[X])}$

The exact value of the expectation of the non-linear function will depend on the particular probability distribution of the random variable ${\displaystyle X}$ .

## Variance algebra for random variables

The variance ( ${\displaystyle Var}$ ) of the random variable ${\displaystyle Z}$  resulting from an algebraic operation between random variables can be calculated using the following set of rules:

• Addition: ${\displaystyle Var[Z]=Var[X+Y]=Var[X]+2Cov[X,Y]+Var[Y]}$ . Particularly, if ${\displaystyle X}$ and ${\displaystyle Y}$ are independent from each other, then: ${\displaystyle Var[X+Y]=Var[X]+Var[Y]}$ .
• Subtraction: ${\displaystyle Var[Z]=Var[X-Y]=Var[X]-2Cov[X,Y]+Var[Y]}$ . Particularly, if ${\displaystyle X}$ and ${\displaystyle Y}$ are independent from each other, then: ${\displaystyle Var[X-Y]=Var[X]+Var[Y]}$ . That is, for independent random variables the variance is the same for additions and subtractions: ${\displaystyle Var[X+Y]=Var[X-Y]=Var[Y-X]=Var[-X-Y]}$
• Multiplication: ${\displaystyle Var[Z]=Var[XY]=Var[YX]}$ . Particularly, if ${\displaystyle X}$ and ${\displaystyle Y}$ are independent from each other, then: ${\displaystyle Var[XY]=E[X^{2}]\cdot E[Y^{2}]-(E[X]\cdot E[Y])^{2}=Var[X]\cdot Var[Y]+Var[X]\cdot (E[Y])^{2}+Var[Y]\cdot (E[X])^{2}}$ .
• Division: ${\displaystyle Var[Z]=Var[X/Y]=Var[X\cdot (1/Y)]=Var[(1/Y)\cdot X]}$ . Particularly, if ${\displaystyle X}$ and ${\displaystyle Y}$ are independent from each other, then: ${\displaystyle Var[X/Y]=E[X^{2}]\cdot E[1/Y^{2}]-(E[X]\cdot E[1/Y])^{2}=Var[X]\cdot Var[1/Y]+Var[X]\cdot (E[1/Y])^{2}+Var[1/Y]\cdot (E[X])^{2}}$ .
• Exponentiation: ${\displaystyle Var[Z]=Var[X^{Y}]=Var[e^{Y\ln(X)}]}$

where ${\displaystyle Cov[X,Y]=Cov[Y,X]}$ represents the covariance operator between random variables ${\displaystyle X}$  and ${\displaystyle Y}$ .

If any of the random variables is replaced by a deterministic variable or by a constant value ( ${\displaystyle k}$ ), the previous properties remain valid considering that ${\displaystyle E[k]=k}$ , ${\displaystyle Var[k]=0}$ and ${\displaystyle Cov[X,k]=0}$ . Special cases are the addition and multiplication of a random variable with a deterministic variable or a constant, where:

• ${\displaystyle Var[X+k]=Var[X]}$
• ${\displaystyle Var[kX]=k^{2}Var[X]}$

If ${\displaystyle Z}$ is defined as a general non-linear algebraic function ${\displaystyle f}$ of a random variable ${\displaystyle X}$ , then:

${\displaystyle Var[Z]=Var[f(X)]\neq f(Var[X])}$

The exact value of the variance of the non-linear function will depend on the particular probability distribution of the random variable ${\displaystyle X}$ .

## Covariance algebra for random variables

The covariance ( ${\displaystyle Cov}$ ) between the random variable ${\displaystyle Z}$  resulting from an algebraic operation and the random variable ${\displaystyle X}$  can be calculated using the following set of rules:

• Addition: ${\displaystyle Cov[Z,X]=Cov[X+Y,X]=Var[X]+Cov[X,Y]}$ . If ${\displaystyle X}$ and ${\displaystyle Y}$ are independent from each other, then: ${\displaystyle Cov[X+Y,X]=Var[X]}$ .
• Subtraction: ${\displaystyle Cov[Z,X]=Cov[X-Y,X]=Var[X]-Cov[X,Y]}$ . If ${\displaystyle X}$ and ${\displaystyle Y}$ are independent from each other, then: ${\displaystyle Cov[X-Y,X]=Var[X]}$ .
• Multiplication: ${\displaystyle Cov[Z,X]=Cov[XY,X]=E[X^{2}Y]-E[XY]E[X]}$ . If ${\displaystyle X}$ and ${\displaystyle Y}$ are independent from each other, then: ${\displaystyle Cov[XY,X]=Var[X]\cdot E[Y]}$ .
• Division (covariance with respect to the numerator): ${\displaystyle Cov[Z,X]=Cov[X/Y,X]=E[X^{2}/Y]-E[X/Y]E[X]}$ . If ${\displaystyle X}$ and ${\displaystyle Y}$ are independent from each other, then: ${\displaystyle Cov[X/Y,X]=Var[X]\cdot E[1/Y]}$ .
• Division (covariance with respect to the denominator): ${\displaystyle Cov[Z,X]=Cov[Y/X,X]=E[Y]-E[Y/X]E[X]}$ . If ${\displaystyle X}$ and ${\displaystyle Y}$ are independent from each other, then: ${\displaystyle Cov[Y/X,X]=E[Y]\cdot (1-E[X]\cdot E[1/X])}$ .
• Exponentiation (covariance with respect to the base): ${\displaystyle Cov[Z,X]=Cov[X^{Y},X]=E[X^{Y+1}]-E[X^{Y}]E[X]}$ .
• Exponentiation (covariance with respect to the power): ${\displaystyle Cov[Z,X]=Cov[Y^{X},X]=E[XY^{X}]-E[Y^{X}]E[X]}$ .

If any of the random variables is replaced by a deterministic variable or by a constant value ( ${\displaystyle k}$ ), the previous properties remain valid considering that ${\displaystyle E[k]=k}$ , ${\displaystyle Var[k]=0}$ and ${\displaystyle Cov[X,k]=0}$ .

If ${\displaystyle Z}$ is defined as a general non-linear algebraic function ${\displaystyle f}$ of a random variable ${\displaystyle X}$ , then:

${\displaystyle Cov[Z,X]=Cov[f(X),X]=E[Xf(X)]-E[f(X)]E[X]}$

The exact value of the variance of the non-linear function will depend on the particular probability distribution of the random variable ${\displaystyle X}$ .

## Approximations by Taylor series expansions of moments

If the moments of a certain random variable ${\displaystyle X}$ are known (or can be determined by integration if the probability density function is known), then it is possible to approximate the expected value of any general non-linear function ${\displaystyle f(X)}$ as a Taylor series expansion of the moments, as follows:

${\displaystyle f(X)=\textstyle \sum _{n=0}^{\infty }\displaystyle {1 \over n!}{\biggl (}{d^{n}f \over dX^{n}}{\biggr )}_{X=\mu }(X-\mu )^{n}}$ , where ${\displaystyle \mu =E[X]}$ is the mean value of ${\displaystyle X}$ .

${\displaystyle E[f(X)]=E{\biggl (}\textstyle \sum _{n=0}^{\infty }\displaystyle {1 \over n!}{\biggl (}{d^{n}f \over dX^{n}}{\biggr )}_{X=\mu }(X-\mu )^{n}{\biggr )}=\textstyle \sum _{n=0}^{\infty }\displaystyle {1 \over n!}{\biggl (}{d^{n}f \over dX^{n}}{\biggr )}_{X=\mu }E[(X-\mu )^{n}]=\textstyle \sum _{n=0}^{\infty }\displaystyle {1 \over n!}{\biggl (}{d^{n}f \over dX^{n}}{\biggr )}_{X=\mu }\mu _{n}(X)}$ , where ${\displaystyle \mu _{n}[X]=E[(X-\mu )^{n}]}$ is the n-th moment of ${\displaystyle X}$  about its mean.

Then,

${\displaystyle E[f(X)]\approx \textstyle \sum _{n=0}^{n_{max}}\displaystyle {1 \over n!}{\biggl (}{d^{n}f \over dX^{n}}{\biggr )}_{X=\mu }\mu _{n}(X)}$ , where the Taylor expansion is truncated after the ${\displaystyle n_{max}}$ -th moment.

Particularly for functions of normal random variables, it is possible to obtain a Taylor expansion in terms of the standard normal distribution:[1]

${\displaystyle f(X)=\textstyle \sum _{n=0}^{\infty }\displaystyle {\sigma ^{n} \over n!}{\biggl (}{d^{n}f \over dX^{n}}{\biggr )}_{X=\mu }\mu _{n}(Z)}$ , where ${\displaystyle X\sim N(\mu ,\sigma ^{2})}$ is a normal random variable, and ${\displaystyle Z\sim N(0,1)}$ is the standard normal distribution. Thus,

${\displaystyle E[f(X)]\approx \textstyle \sum _{n=0}^{n_{max}}\displaystyle {\sigma ^{n} \over n!}{\biggl (}{d^{n}f \over dX^{n}}{\biggr )}_{X=\mu }\mu _{n}(Z)}$ , where the moments of the standard normal distribution are given by:

${\displaystyle \mu _{n}(Z)={\begin{cases}\prod _{i=1}^{n/2}(2i-1),&{\text{if }}n{\text{ is even}}\\0,&{\text{if }}n{\text{ is odd}}\end{cases}}}$

Similarly for normal random variables, it is also possible to approximate the variance of the non-linear function as a Taylor series expansion as:

${\displaystyle Var[f(X)]\approx \textstyle \sum _{n=1}^{n_{max}}\displaystyle {\biggl (}{\sigma ^{n} \over n!}{\biggl (}{d^{n}f \over dX^{n}}{\biggr )}_{X=\mu }{\biggr )}^{2}Var[Z^{n}]+\textstyle \sum _{n=1}^{n_{max}}\displaystyle \textstyle \sum _{m\neq n}\displaystyle {\sigma ^{n+m} \over {n!m!}}{\biggl (}{d^{n}f \over dX^{n}}{\biggr )}_{X=\mu }{\biggl (}{d^{m}f \over dX^{m}}{\biggr )}_{X=\mu }Cov[Z^{n},Z^{m}]}$ , where

${\displaystyle Var[Z^{n}]={\begin{cases}\prod _{i=1}^{n}(2i-1)-\prod _{i=1}^{n/2}(2i-1)^{2},&{\text{if }}n{\text{ is even}}\\\prod _{i=1}^{n}(2i-1),&{\text{if }}n{\text{ is odd}}\end{cases}}}$ , and

${\displaystyle Cov[Z^{n},Z^{m}]={\begin{cases}\prod _{i=1}^{(n+m)/2}(2i-1)-\prod _{i=1}^{n/2}(2i-1)\prod _{j=1}^{m/2}(2j-1),&{\text{if }}n{\text{ and }}m{\text{ are even}}\\\prod _{i=1}^{(n+m)/2}(2i-1),&{\text{if }}n{\text{ and }}m{\text{ are odd}}\\0,&{\text{otherwise}}\end{cases}}}$

## Algebra of complex random variables

In the algebraic axiomatization of probability theory, the primary concept is not that of probability of an event, but rather that of a random variable. Probability distributions are determined by assigning an expectation to each random variable. The measurable space and the probability measure arise from the random variables and expectations by means of well-known representation theorems of analysis. One of the important features of the algebraic approach is that apparently infinite-dimensional probability distributions are not harder to formalize than finite-dimensional ones.

Random variables are assumed to have the following properties:

1. complex constants are possible realizations of a random variable;
2. the sum of two random variables is a random variable;
3. the product of two random variables is a random variable;
4. addition and multiplication of random variables are both commutative; and
5. there is a notion of conjugation of random variables, satisfying (XY)* = Y*X* and X** = X for all random variables X,Y and coinciding with complex conjugation if X is a constant.

This means that random variables form complex commutative *-algebras. If X = X* then the random variable X is called "real".

An expectation E on an algebra A of random variables is a normalized, positive linear functional. What this means is that

1. E[k] = k where k is a constant;
2. E[X*X] ≥ 0 for all random variables X;
3. E[X + Y] = E[X] + E[Y] for all random variables X and Y; and
4. E[kX] = kE[X] if k is a constant.

One may generalize this setup, allowing the algebra to be noncommutative. This leads to other areas of noncommutative probability such as quantum probability, random matrix theory, and free probability.