mml-book / mml-book.github.io

Companion webpage to the book "Mathematics For Machine Learning"
13.04k stars 2.41k forks source link

Latex file for the List of Symbols table #634

Closed harrywang closed 3 years ago

harrywang commented 3 years ago

Is your feature request related to a problem? Please describe. A clear and concise description of what the problem is. Ex. I'm always frustrated when [...] Is it possible to share the Latex file for the list of symbols table in the book? Describe the solution you'd like A clear and concise description of what you want to happen. The Latex file for the list of symbols table in the book? Describe alternatives you've considered A clear and concise description of any alternative solutions or features you've considered. If not, I will try to write a version and share if it is OK with the authors. Additional context Add any other context or screenshots about the feature request here. Thanks a lot for the great book!!!

chengsoonong commented 3 years ago

I am trying to understand why the LaTeX source is needed?

harrywang commented 3 years ago

@chengsoonong thanks for the reply. I try to teach students to write latex and want them to rewrite some formulas in the book using Jupyter. I want to give them the latex for the list of symbols as a starter. Thanks.

chengsoonong commented 3 years ago

You mean something like this?

In the preamble: \renewcommand{\vec}[1]{{\boldsymbol{{#1}}}} % vector \renewcommand{\geq}{\geqslant} \renewcommand{\leq}{\leqslant} \newcommand{\mat}[1]{{\boldsymbol{{#1}}}} % matrix \newcommand{\tensor}[1]{\mathbb{#1}} % tensor \newcommand{\tr}[0]{\text{tr}} % trace \newcommand{\inv}{^{-1}} % inverse \renewcommand{\dim}{\mathrm{dim}} % dimension \newcommand{\rank}[0]{\mathrm{rk}} % rank \newcommand{\determ}[1]{\mathrm{det}(#1)} % determinant \renewcommand{\d}{\mathrm{d}}

In the main document:

\section*{Table of Symbols} \begin{tabular}{l l} \hline Symbol & Typical meaning\ \hline \hline $a,b,c, \alpha,\beta,\gamma$ & Scalars are lowercase\ $\vec x,\vec y,\vec z$ & Vectors are bold lowercase\ $\mat A,\mat B,\mat C$ & Matrices are bold uppercase\ $\vec x\T, \mat A\T$ & Transpose of a vector or matrix\ $\mat A\inv$ & Inverse of a matrix\ $\scp{\vec x}{\vec y}$ & Inner product of $\vec x$ and $\vec y$\ $\vec x \T \vec y$ & Dot product of $\vec x$ and $\vec y$\ $B = (\vec b_1, \vec b_2, \vec b_3)$ & (Ordered) tuple\ $\mat B = [\vec b_1, \vec b_2, \vec b_3]$ & Matrix of column vectors stacked horizontally\ $\set B = {\vec b_1, \vec b_2, \vec b_3}$ & Set of vectors (unordered)\ $\ZZ,\NN$ & Integers and natural numbers, respectively\ $\RR,\CC$ & Real and complex numbers, respectively\ $\RR^n$& $n$-dimensional vector space of real numbers\ %$\RR^D$& $D$-dimensional vector space of real numbers & 2nd half % notation\ %Individual symbols with specific meanings\ \hline % Operators $\forall x$ & Universal quantifier: for all $x$\ $\exists x$ & Existential quantifier: there exists $x$\ $a := b$ & $a$ is defined as $b$\ $a =:b$ & $b$ is defined as $a$\ $a\propto b$ & $a$ is proportional to $b$, i.e., $a = \text{constant}\cdot b$\ $g\circ f$ & Function composition: ``$g$ after $f$''\ $\iff$ & If and only if \ $\implies$ & Implies\ $\set A, \set C$ & Sets \ $a \in \set A$ & $a$ is an element of set $\set A$\ $\emptyset$ & Empty set\ $\set A\setminus \set B$ & $\set A$ without $\set B$: the set of elements in $\set A$ but not in $\set B$\ $D$ & Number of dimensions; indexed by $d=1,\dots,D$\ $N$ & Number of data points; indexed by $n=1,\dots,N$\ %$n,m$ & Dimensions of vector spaces & 1st half notation \ \hline $\eyem$ & Identity matrix of size $m\times m$\ $\zeros{m,n}$ & Matrix of zeros of size $m\times n$\ $\ones_{m,n}$ & Matrix of ones of size $m\times n$\ $\vec e_i$ & Standard\slash canonical vector (where $i$ is the component that is $1$) \ $\dim$ & Dimensionality of vector space \ $\rank(\mat A)$ & Rank of matrix $\mat A$\ $\img(\Phi)$ & Image of linear mapping $\Phi$\ $\kernel(\Phi)$ & Kernel (null space) of a linear mapping $\Phi$\ $\genset{\vec b_1}$ & Span (generating set) of $\vec b1$\ $\tr(\mat A)$ & Trace of $\mat A$\ $\det(\mat A)$ & Determinant of $\mat A$\ $| \cdot |$ & Absolute value or determinant (depending on context)\ $\norm{\cdot}$ & Norm; Euclidean, unless specified\ $\lambda$ & Eigenvalue or Lagrange multiplier\ $E\lambda$ & Eigenspace corresponding to eigenvalue $\lambda$\ \hline \end{tabular}

chengsoonong commented 3 years ago

Could you share a link to your course please? It is nice for us to know where the book is being used.

harrywang commented 3 years ago

Thanks a lot!! Can you also provide the packages you used? For example, \boldsymbol can be replaced by \bm with \usepackage{bm}.

harrywang commented 3 years ago

Could you share a link to your course please? It is nice for us to know where the book is being used.

Here you go: http://harrywang.me/misy331/ Thanks again for the great book!

harrywang commented 3 years ago

https://www.overleaf.com/read/mnzgdyrsjfsk @chengsoonong based on your input, I added some packages, changed a few commands (boldsymbol, transpose, identity/zero/one matrix, integers and natural numbers, etc), and wrote this on overleaf - I cannot get set symbols to look like what you had in the book - any suggestions? Thanks.

chengsoonong commented 3 years ago

Some more commands

\newcommand{\id}{\mathrm{id}} % identity mapping \newcommand{\kernel}[0]{\mathrm{ker}} % kernel/nullspace \newcommand{\img}[0]{\mathrm{Im}} % image \newcommand{\idx}[1]{{(#1)}} \newcommand{\genset}[1]{\mathrm{span}[#1]} % generating set

\DeclareMathOperator*{\diag}{diag} \ifxetex \renewcommand{\T}[0]{^\top} % transpose \else \newcommand{\T}[0]{^\top} \fi \newcommand{\matdet}[1]{ \left| \begin{matrix}

1

\end{matrix} \right| } \newcommand{\ones}{\mat{1}} \newcommand{\zeros}{\mat{0}} \newcommand{\eye}{\mat I} % Identity matrix

\newcommand{\set}[1]{\mathcal{#1}} % set

\newcommand{\RR}{\mathds{R}} % real numbers \newcommand{\NN}{\mathds{N}} % natural numbers \newcommand{\ZZ}{\mathds{Z}} % integers \newcommand{\QQ}{\mathds{Q}} % rational numbers \newcommand{\CC}{\mathds{C}} % complex numbers

harrywang commented 3 years ago

Thanks a lot! I have updated the file with your new inputs: https://www.overleaf.com/read/mnzgdyrsjfsk

harrywang commented 3 years ago

@chengsoonong do you mind sharing the latex for the remaining part of the table shown below? Thanks!

Screen Shot 2021-02-19 at 11 43 06 AM
harrywang commented 3 years ago

I also created a Jupyter Notebook version at: https://colab.research.google.com/drive/15cQSy8AvU_0ChtNfYaW_Wqfj_dgPv_Lq some minor changes were made to make some symbols to work for Juptyer.

chengsoonong commented 3 years ago

The table:

\begin{tabular}{l l} \hline Symbol & Typical meaning\ \hline \hline $\vec x\perp\vec y$ & Vectors $\vec x$ and $\vec y$ are orthogonal\ $V$ & Vector space\ $V^\perp$ & Orthogonal complement of vector space $V$\ $\sum_{n=1}^N x_n$ & Sum of the $x_n$: $x_1 + \dotsc + xN$\ $\prod{n=1}^N x_n$ & Product of the $x_n$: $x_1 \cdot\dotsc \cdot xN$\ $\vec\theta$ & Parameter vector\ $\pdiffF{f}{x}$ & Partial derivative of $f$ with respect to $x$\ $\diffF{f}{x}$ & Total derivative of $f$ with respect to $x$\ $\nabla$ & Gradient \ $f = \minx f(x)$ & The smallest function value of $f$\ $x \in \arg\minx f(x)$ & The value $x*$ that minimizes $f$ (note: $\arg\min$ returns a set of values)\ $\lag$ & Lagrangian \ $\lik$ & Negative log-likelihood\ $\binom{n}{k}$ & Binomial coefficient, $n$ choose $k$\ $\var_X[\vec x]$ & Variance of $\vec x$ with respect to the random variable $X$\ $\EX[\vec x]$ & Expectation of $\vec x$ with respect to the random variable $X$\ $\cov{X,Y}[\vec x, \vec y]$ & Covariance between $\vec x$ and $\vec y$.\ $X \dsep Y\given Z$ & $X$ is conditionally independent of $Y$ given $Z$\ $X\sim p$ & Random variable $X$ is distributed according to $p$\ $\gauss{\mat \mu}{\mat \Sigma}$ & Gaussian distribution with mean $\vec \mu$ and covariance $\mat \Sigma$ \ $\Ber(\mu)$ & Bernoulli distribution with parameter $\mu$\ $\Bin(N, \mu)$ & Binomial distribution with parameters $N, \mu$\ $\Beta(\alpha, \beta)$ & Beta distribution with parameters $\alpha, \beta$\ \hline \end{tabular}

chengsoonong commented 3 years ago

preamble:

% probabilities and statistics \newcommand{\var}{\mathds{V}} % variance \DeclareMathOperator{\cov}{Cov} % covariance \newcommand{\E}{\mathds{E}} % expectation %\newcommand{\state}[1]{{\normalfont\textsc{#1}}} % The state of a random variable \newcommand{\state}[1]{#1} % The state of a random variable

\newcommand{\lik}{\mathcal{L}} % likelihood \newcommand{\lag}{\mathfrak{L}} % lagrangian

% Gaussian distribution \newcommand{\gauss}[2]{\mathcal{N}\big(#1,\,#2\big)} % other distributions \newcommand{\Ber}{\text{Ber}} \newcommand{\Bin}{\text{Bin}} \newcommand{\Beta}{\text{Beta}}

% D-separation criteria (conditional independence) \providecommand{\dsep}{\mathrel{\perp\mspace{-10mu}\perp}}

% calculus \newcommand{\pdiffF}[2]{\frac{\partial #1}{\partial #2}} \newcommand{\diffF}[2]{\frac{{\d}#1}{{\d}#2}}

harrywang commented 3 years ago

Thanks a lot. I changed a few commands to make them work for Jupyter notebook.

The final version: Jupyter Notebook: https://colab.research.google.com/drive/15cQSy8AvU_0ChtNfYaW_Wqfj_dgPv_Lq Overleaf: https://www.overleaf.com/read/mnzgdyrsjfsk