Notation

This author firmly holds the (seemingly unpopular) view that good notation makes mathematical texts much easier to understand. More precisely, bad notation is much easier to parse—indeed, unremarkable—when one has already mastered the concepts; it can also mask deep underlying conceptual issues. I have attempted, although not everywhere with success, to use good notation in what follows.

symbol use
X{X}, Y{Y}, Z{Z} scalar random variables
xx, yy, zz scalar instantiations
𝑿{\bm{X}}, 𝒀{\bm{Y}}, 𝒁{\bm{Z}} vector random variables
𝒙\bm{x}, 𝒚\bm{y}, 𝒛\bm{z} vector instantiations
𝐀,𝐁,𝐂,𝐏\mathbf{A},\mathbf{B},\mathbf{C},\mathbf{P}, etc. matrices
𝜽,ϕ\bm{\theta},\bm{\phi} (non-random) parameters
𝝅\bm{\pi} vector of categorical
   probabilities (kπk=1\sum_{k}\pi_{k}=1)
𝝁\bm{\mu} mean (vector)
𝚺\mathbf{{\Sigma}} covariance matrix

Basic symbols.

Basic notational conventions are for the most part standard. This book uses capital letters for random variables, lowercase for their instantiations, boldface italic font for vectors, and italic for scalar variables. The (generally Latin) letters for matrices are capitalized and bolded, but (unless random) in Roman font, and not necessarily from the front of the alphabet.

The set of all standard parameters (like means, variances, and the like) of a distribution are generally denoted as a single vector with either 𝜽\bm{\theta} or ϕ\bm{\phi} (or, in a pinch, some nearby Greek letter). But note well that in the context of Bayesian statistics their status as random variables is marked in the notation: 𝚯\bm{\Theta}, 𝚽\bm{\Phi}. The Greek letters 𝝅\bm{\pi}, 𝝁\bm{\mu}, and 𝚺\mathbf{{\Sigma}}{} are generally reserved for particular parameters: the vector of categorical probabilities, the mean (vector), and the covariance matrix, respectively. Note that we do not use π\pi for the transcendental constant; we use τ=2π\tau=2\pi [11].

Arguments and variables

In this textbook, I distinguish notationally between the arguments of functions (on the one hand) and variables, at which a function might be evaluated (on the other). Why?

An ambiguity in argument binding.

In standard notation, a function might be defined with the expression

f(x) . . =x2.f(x)\mathrel{\vbox{\hbox{\scriptsize.}\hbox{\scriptsize.} }}=x^{2}. (1.1)

Although this usually causes no problems, note that xx does not indicate any particular value; or, to put it another way, the expression is completed by an implicit (omitted) x\forall x. On the occasions that we do not intend universal quantification, then, problems can arise. For example suppose we want to say that the unary function ff is identical to the binary function gg when its second argument is set to the value yy (or, alternatively, that such a value exists: y\exists y). We could write

f(x)=g(x,y),f(x)=g(x,y),

but the fact that we are (mentally) to insert x\forall x but not y\forall y is not evident from the equation, but only from the surrounding verbal context.

There are several standard alternatives, but none is wholly satisfactory. We could include all quantifiers whenever there is ambiguity—but ambiguity is often in the eye of the beholder, and it is dangerous for a textbook to assume that an expression is perfectly transparent. We could simply include all quantifiers, but equations with many arguments would be littered with \forall statements. Or again, we could use the mechanism of raised dots,

f()=g(,y),f(\cdot)=g(\cdot,y),

although yy still violates the standard convention in being unbound to a universal quantifier, and this has to be extracted from the verbal context. But more fatally, this mechanism doesn’t generalize well to functions of more variables:

f(,)=g(,y,).f(\cdot,\cdot)=g(\cdot,y,\cdot).

Which dots on the left corresponds to which on the right?

Subscripts to the rescue?

Now, in a statistics textbook, the probability-mass function associated with a discrete random variable X{X} is usually written pXp_{{X}} or (to emphasize that it is a function) pX()p_{{X}}(\cdot), and the probability of a particular observation xx correspondingly as pX(x)p_{{X}}(x). The subscript distinguishes this mass function from, say, one associated with the random variable Y{Y}, namely pYp_{{Y}}. Conditional distribributions, in turn, are written pY|Xp_{{Y}|{X}}, and the value of a conditional distribution pY|X(y|x)p_{{Y}|{X}}(y|x). This might seem exactly the mechanism we seek to identify the (universally quantified) arguments of functions. For example, consider this instance of Bayes’ rule:

pX|Y,Z(|,z)=pY|X,Z(|,z)pX|Z(|z)pY|Z(|z).p_{{X}{}|{Y}{},{Z}}(\cdot|\cdot,z)=\frac{p_{{Y}{}|{X}{},{Z}}(\cdot|\cdot,z)p_{% {X}{}|{Z}}(\cdot|z)}{p_{{Y}{}|{Z}}(\cdot|z)}. (1.2)

The convention for understanding it is that omitted arguments (x,yx,y) are universally quantified, whereas included variables (zz) have been bound to something in the enclosing context.

But this proposal, too, has problems. First of all, although the subscripts make it possible to infer which omitted arguments on the left correspond to which on the right, the dots themselves are just noise. For the reader that is not convinced by Eq. 1.2, I suggest

p𝑿1,,𝑿T,𝒀1,,𝒀T(,,,,𝒚1,,𝒚T)=t=1Tp𝑿t|𝑿t-1(|)p𝒀t|𝑿t(𝒚t|),p_{{\bm{X}}_{1},\ldots,{\bm{X}}_{{T}},{\bm{Y}}_{1},\ldots,{\bm{Y}}_{{T}}}(% \cdot,\cdot,\ldots,\cdot,\bm{y}_{1},\ldots,\bm{y}_{{T}})=\prod_{t=1}^{{{T}}}p_% {{\bm{X}}_{t}|{\bm{X}}_{t-1}}(\cdot|\cdot)p_{{\bm{Y}}_{t}|{\bm{X}}_{t}}(\bm{y}% _{t}|\cdot), (1.3)

a partially evaluated function that we will encounter in Chapter 2. Second (what is fatal), raised dots can’t be used for variables occurring outside of the list of function arguments. For example, how are we to write Eq. 1.1?—certainly not

f() . . =2.f(\cdot)\mathrel{\vbox{\hbox{\scriptsize.}\hbox{\scriptsize.} }}=\cdot^{2}. (1.4)

Gray arguments.

We can get a hold of the fundamental issue that we are grappling with here by distinguishing function arguments from variables. This is most intuitive in terms of a programming language. For example, in the following snippet of (Python) code,


                  1
                def quadratic(x):


                  2
                    return (x - c)**2

x is an argument to the quadratic function, whereas c is a variable that is (presumably) bound somewhere in the enclosing scope. Critically, x is an argument both in the function declaration, def quadratic(x):, and in the function body, return (x - c)**2. A function can also be defined as a partially evaluated instance of another function:


                  1
                def shifted_quadratic(x, c):


                  2
                    return (x-c)**2


                  3
                


                  4
                def centered_quadratic(x):


                  5
                    return shifted_quadratic(x,0)

Both x amd c are arguments of shifted_quadratic, but centered_quadratic has only a single argument, x. It is analogous to the partially evaluated function exhibited in Eq. 1.3, whose only arguments are 𝒙1,,𝒙T\bm{x}_{1},\ldots,\bm{x}_{{T}}.

With some reservations, I have introduced a new notational convention in this book to mark this distinction between arguments and variables, employing a gray font color for the former. For example, Eq. 1.3 will be written as

p(𝒙1,,𝒙T,𝒚1,,𝒚T)=t=1Tp(𝒙t|𝒙t-1)p(𝒚t|𝒙t).p(\leavevmode\color[rgb]{.5,.5,.5}\definecolor[named]{pgfstrokecolor}{rgb}{% .5,.5,.5}\pgfsys@color@gray@stroke{.5}\pgfsys@color@gray@fill{.5}\bm{x}_{1},% \ldots,\bm{x}_{{T}},\bm{y}_{1},\ldots,\bm{y}_{{T}})=\prod_{t=1}^{{{T}}}p(% \leavevmode\color[rgb]{.5,.5,.5}\definecolor[named]{pgfstrokecolor}{rgb}{% .5,.5,.5}\pgfsys@color@gray@stroke{.5}\pgfsys@color@gray@fill{.5}\bm{x}_{t}|% \leavevmode\color[rgb]{.5,.5,.5}\definecolor[named]{pgfstrokecolor}{rgb}{% .5,.5,.5}\pgfsys@color@gray@stroke{.5}\pgfsys@color@gray@fill{.5}\bm{x}_{t-1})% p(\bm{y}_{t}|\leavevmode\color[rgb]{.5,.5,.5}\definecolor[named]{% pgfstrokecolor}{rgb}{.5,.5,.5}\pgfsys@color@gray@stroke{.5}% \pgfsys@color@gray@fill{.5}\bm{x}_{t}). (1.5)

As in Eq. 1.3, the fact that the function is partially evaluated at 𝒚1,,𝒚T\bm{y}_{1},\ldots,\bm{y}_{{T}} is indicated, but in this case with the standard (black) font.

This notational convention neatly solves the problems just discussed. That is, it makes clear which variables are universally quantified—namely, the arguments, in gray—without resorting to explicit quantification, verbal context, or subscripts and dots. This last is particularly appealing not just because it is easier to read and generalizes better (recall Eq. 1.4), although these are its chief merits. It also provides an alternative mechanism for disambiguating probability-mass and -density functions from each other; namely, by their (gray) arguments rather than by subscripts. Indeed, this is the standard device employed in the machine-learning literature—but without the distinction between arguments and variables that solves our main problem.

And then, finally, we will see below that this distinction is exceedingly useful for another purpose: distinguishing partial and total derivatives.

Probabilistical functions and functionals

Symbols for probability mass and density.

symbol use
pp the data mass/density function
p^\hat{p}, pˇ\check{p} the model mass/density functions

This text indiscriminately uses the same letter for probability-mass and probability-density functions, in both cases the usual (for mass functions) pp. Further semantic content is, however, communicated by diacritics. In particular, pp is reserved for “the data distribution,” i.e., the true source in the world of our samples, as opposed to a model. Often in the literature, but not in this book, the data distribution is taken to be a discrete set of points corresponding to a particular sample, that is, a collection of delta functions. Here, pp is interpreted to be a full-fledged distribution, known not in form but only through the samples that we have observed from it.

For model distributions we generally employ p^\hat{p}, although we shall also have occasion to use pˇ\check{p} for certain model distributions.

Now, it is a fact from elementary probability theory [XXX] that a random variable carries with it a probability distribution. Conversely, it makes no sense to talk about two different probability distributions over the same random variable—although texts on machine learning routinely do, usually in the context of relative or cross entropy [GoodfellowXXX]. We will indeed often be interested in (e.g.) the relative entropy (KL divergence) of two distributions, pp and p^\hat{p}, but this text takes pains to note that these are distributions over different random variables, for example Y{Y} and Y^{\hat{Y}}, respectively. In general, the text marks random variables, their corresponding distributions, and the arguments of those distributions with the same diacritics; hence,

Yp(y),\displaystyle{Y}\sim{p\mathopen{}\mathclose{{}\left(\leavevmode\color[rgb]{% .5,.5,.5}\definecolor[named]{pgfstrokecolor}{rgb}{.5,.5,.5}% \pgfsys@color@gray@stroke{.5}\pgfsys@color@gray@fill{.5}y}\right)}, Y^p^(y^;𝜽).\displaystyle{\hat{Y}}\sim{\hat{p}\mathopen{}\mathclose{{}\left(\leavevmode% \color[rgb]{.5,.5,.5}\definecolor[named]{pgfstrokecolor}{rgb}{.5,.5,.5}% \pgfsys@color@gray@stroke{.5}\pgfsys@color@gray@fill{.5}\hat{y};\bm{\theta}}% \right)}.

It may at first blush seem surprising, then, to see the relative entropy (KL divergence) expressed as

DKL{p(Y)p^(Y;𝜽)},\operatorname*{\text{D}_{\text{KL}}}\mathopen{}\mathclose{{}\left\{{p\mathopen% {}\mathclose{{}\left({Y}}\right)}\middle\|{\hat{p}\mathopen{}\mathclose{{}% \left({Y};\bm{\theta}}\right)}}\right\},

that is, with Y{Y} on both sides. But Y{Y} is not an argument of these distributions; it is the variable at which they are being evaluated. Notice that despite the arguments not appearing in this expression, the two distributions are still distinguishable—by their diacritics.

Still, the conventions are not bulletproof. Consider for example density functions for two different data distributions:

Xp(x),\displaystyle{X}\sim{p\mathopen{}\mathclose{{}\left(\leavevmode\color[rgb]{% .5,.5,.5}\definecolor[named]{pgfstrokecolor}{rgb}{.5,.5,.5}% \pgfsys@color@gray@stroke{.5}\pgfsys@color@gray@fill{.5}x}\right)}, Yp(y).\displaystyle{Y}\sim{p\mathopen{}\mathclose{{}\left(\leavevmode\color[rgb]{% .5,.5,.5}\definecolor[named]{pgfstrokecolor}{rgb}{.5,.5,.5}% \pgfsys@color@gray@stroke{.5}\pgfsys@color@gray@fill{.5}y}\right)}.

These are distinguished not by any diacritics, but by their arguments. According to our convention, these arguments are generally listed (in gray), so it is usually possible to tell these two distributions apart. And even when considering evaluated density functions, we can typically disambiguate by our choice for the letter used for the observations: p(x),p(y){p\mathopen{}\mathclose{{}\left(x}\right)},{p\mathopen{}\mathclose{{}\left(y}% \right)}. Occasionally, however, we will need to consider evaluating such functions at some other point, say zz or 1. Then we will be thrown back on one of the other, standard conventions: p(Y=1){p\mathopen{}\mathclose{{}\left({Y}=1}\right)}, pY(z)p_{{Y}}(z), etc.

symbol use
𝔼[𝑿]\mathbb{E}{\mathopen{}\mathclose{{}\left[{\bm{X}}}\right]} expectation of 𝑿{\bm{X}}
𝑿{\mathopen{}\mathclose{{}\left\langle{{\bm{X}}}}\right\rangle} sample average of 𝑿{\bm{X}}
Var[X]\text{Var}{\mathopen{}\mathclose{{}\left[{X}{}}\right]} variance of X{X}{}
Cov[𝑿]\text{Cov}{\mathopen{}\mathclose{{}\left[{\bm{X}}}\right]} covariance matrix of 𝑿{\bm{X}}
Cov[𝑿,𝒀]\text{Cov}{\mathopen{}\mathclose{{}\left[{\bm{X}},{\bm{Y}}}\right]} covariance between 𝑿{\bm{X}} and 𝒀{\bm{Y}}

Expectation, covariance, and sample averages.

The symbol Cov[]\text{Cov}{\mathopen{}\mathclose{{}\left[\cdot}\right]} is used with a single argument to denote the operator that turns a random variable into a covariance matrix; but with two arguments, Cov[,]\text{Cov}{\mathopen{}\mathclose{{}\left[\cdot,\cdot}\right]}, to indicate the (cross) covariance between two random variables. Perhaps more idiosyncratically, angle brackets, {\mathopen{}\mathclose{{}\left\langle{\cdot}}\right\rangle}, are usually reserved for sample averages, as opposed to expectation values, although occasionally this stricture is relaxed.

The distribution with respect to which an expectation is taken will only occasionally be inferrable from its argument, so we will typically resort to subscripts (the previous discussion not withstanding). For example, we will write

𝔼𝑿[-logp(𝑿)]\displaystyle\mathbb{E}_{{\bm{X}}{}}{\mathopen{}\mathclose{{}\left[-\log{p% \mathopen{}\mathclose{{}\left({\bm{X}}}\right)}}\right]} 𝔼𝑿|𝒀[-logp(𝑿|𝒚)|𝒚]\displaystyle\mathbb{E}_{{\bm{X}}{}|{\bm{Y}}}{\mathopen{}\mathclose{{}\left[-% \log{p\mathopen{}\mathclose{{}\left({\bm{X}}\middle|\bm{y}}\right)}\middle|\bm% {y}{}}\right]} 𝔼𝑿|𝒀[-logp(𝑿|𝒛)|𝒛]\displaystyle\mathbb{E}_{{\bm{X}}{}|{\bm{Y}}}{\mathopen{}\mathclose{{}\left[-% \log{p\mathopen{}\mathclose{{}\left({\bm{X}}\middle|\bm{z}}\right)}\middle|\bm% {z}{}}\right]}

Thus, e.g., the subscripts in the second and third examples tell us that the expectation is taken under the distribution p(𝒙|𝒚){p\mathopen{}\mathclose{{}\left(\leavevmode\color[rgb]{.5,.5,.5}\definecolor[% named]{pgfstrokecolor}{rgb}{.5,.5,.5}\pgfsys@color@gray@stroke{.5}% \pgfsys@color@gray@fill{.5}\bm{x}{}\middle|\leavevmode\color[rgb]{.5,.5,.5}% \definecolor[named]{pgfstrokecolor}{rgb}{.5,.5,.5}\pgfsys@color@gray@stroke{.5% }\pgfsys@color@gray@fill{.5}\bm{y}{}}\right)}. Of course, only the variable 𝑿{\bm{X}} is averaged out in these expressions; the conditioning variable is free to take on any value, which need not match the argument symbol (as in the third example).

Let us put together some of our conventions with an iterated expectation under p(𝒙|𝒚){p\mathopen{}\mathclose{{}\left(\leavevmode\color[rgb]{.5,.5,.5}\definecolor[% named]{pgfstrokecolor}{rgb}{.5,.5,.5}\pgfsys@color@gray@stroke{.5}% \pgfsys@color@gray@fill{.5}\bm{x}{}\middle|\leavevmode\color[rgb]{.5,.5,.5}% \definecolor[named]{pgfstrokecolor}{rgb}{.5,.5,.5}\pgfsys@color@gray@stroke{.5% }\pgfsys@color@gray@fill{.5}\bm{y}{}}\right)} and p(𝒚){p\mathopen{}\mathclose{{}\left(\leavevmode\color[rgb]{.5,.5,.5}\definecolor[% named]{pgfstrokecolor}{rgb}{.5,.5,.5}\pgfsys@color@gray@stroke{.5}% \pgfsys@color@gray@fill{.5}\bm{y}{}}\right)},

𝔼𝒀[𝔼𝑿|𝒀[f(𝑿,𝒀)|𝒀]]=𝒚p(𝒚)𝒙p(𝒙|𝒚)f(𝒙,𝒚)d𝒙d𝒚.\mathbb{E}_{{\bm{Y}}{}}{\mathopen{}\mathclose{{}\left[\mathbb{E}_{{\bm{X}}{}|{% \bm{Y}}}{\mathopen{}\mathclose{{}\left[f({\bm{X}},{\bm{Y}})\middle|{\bm{Y}}{}}% \right]}}\right]}=\int_{\bm{y}{}}{p\mathopen{}\mathclose{{}\left(\bm{y}}\right% )}\int_{\bm{x}{}}{p\mathopen{}\mathclose{{}\left(\bm{x}\middle|\bm{y}}\right)}% f(\bm{x},\bm{y})\mathop{}\!\mathrm{d}{\bm{x}{}}\mathop{}\!\mathrm{d}{\bm{y}{}}.

There are a few things to notice. First of all, 𝒙\bm{x} and 𝒚\bm{y} do not appear in gray. This is because they are dummy variables, not arguments; or, to put it a different way, they are bound to the integral operaters, not (implicitly) to universal quantifiers. (Accordingly, they do not appear outside of the integrals, e.g. on the other side of the equation.) Second, bear in mind that the symbol on the right side of the conditioning bar (here, 𝒀{\bm{Y}}) need not match the subscript of the outer expectation (here also 𝒀{\bm{Y}}); e.g.,

𝔼𝒀[𝔼𝑿^|𝒀^[f(𝑿^,𝒀)|𝒀]]=𝒚p(𝒚)𝒙^p^(𝒙^|𝒚;𝜽)f(𝒙^,𝒚)d𝒙^d𝒚.\mathbb{E}_{{\bm{Y}}{}}{\mathopen{}\mathclose{{}\left[\mathbb{E}_{{\bm{\hat{X}% }}{}|{\bm{\hat{Y}}}}{\mathopen{}\mathclose{{}\left[f({\bm{\hat{X}}},{\bm{Y}})% \middle|{\bm{Y}}{}}\right]}}\right]}=\int_{\bm{y}{}}{p\mathopen{}\mathclose{{}% \left(\bm{y}}\right)}\int_{\bm{\hat{x}}{}}{\hat{p}\mathopen{}\mathclose{{}% \left(\bm{\hat{x}}\middle|\bm{y};\bm{\theta}}\right)}f(\bm{\hat{x}},\bm{y})% \mathop{}\!\mathrm{d}{\bm{\hat{x}}{}}\mathop{}\!\mathrm{d}{\bm{y}{}}.

Thus, the subscripts to the conditional expectation tell us that it is taken with respect to p^(𝒙^|𝒚^;𝜽){\hat{p}\mathopen{}\mathclose{{}\left(\leavevmode\color[rgb]{.5,.5,.5}% \definecolor[named]{pgfstrokecolor}{rgb}{.5,.5,.5}\pgfsys@color@gray@stroke{.5% }\pgfsys@color@gray@fill{.5}\bm{\hat{x}}{}\middle|\leavevmode\color[rgb]{% .5,.5,.5}\definecolor[named]{pgfstrokecolor}{rgb}{.5,.5,.5}% \pgfsys@color@gray@stroke{.5}\pgfsys@color@gray@fill{.5}\bm{\hat{y}}{};\bm{% \theta}}\right)}, but we are not forbidden from filling the vacant argument 𝒚^\leavevmode\color[rgb]{.5,.5,.5}\definecolor[named]{pgfstrokecolor}{rgb}{% .5,.5,.5}\pgfsys@color@gray@stroke{.5}\pgfsys@color@gray@fill{.5}\bm{\hat{y}} with a different random variable, in this case 𝒀{\bm{Y}}, and taking an expectation.

Third, the “vector differentials” are to be interpreted as

d𝒙 . . =dx1dx1dxK,\mathop{}\!\mathrm{d}{\bm{x}}\mathrel{\vbox{\hbox{\scriptsize.}\hbox{% \scriptsize.} }}=\mathop{}\!\mathrm{d}{x_{1}}\mathop{}\!\mathrm{d}{x_{1}}\cdots\mathop{}\!% \mathrm{d}{x_{{K}}},

and the integral as an iterated integral; hence:

𝒙f(𝒙)d𝒙=xKx2x1f(𝒙)dx1dx2ddxK.\int_{\bm{x}{}}f(\bm{x})\mathop{}\!\mathrm{d}{\bm{x}{}}=\int_{x_{{K}}{}}\int_{% \cdots{}}\int_{x_{2}{}}\int_{x_{1}{}}f(\bm{x})\mathop{}\!\mathrm{d}{x_{1}{}}% \mathop{}\!\mathrm{d}{x_{2}{}}\mathop{}\!\mathrm{d}{\cdots{}}\mathop{}\!% \mathrm{d}{x_{{K}}{}}.

The subscript to the integral tells us that it is to be taken over the entire support of the corresponding random variable.

Derivatives

[[The use of transposes in vector (and matrix) derivatives. The total derivative vs. partial derivatives. The “gradient” and the Hessian.]]