-
Notifications
You must be signed in to change notification settings - Fork 54
Expand file tree
/
Copy pathvimacros.sty
More file actions
86 lines (65 loc) · 2.42 KB
/
vimacros.sty
File metadata and controls
86 lines (65 loc) · 2.42 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
\ProvidesPackage{vimacros}
\usepackage{amsmath, amssymb, xifthen, xstring}
% Support
\DeclareMathOperator{\supp}{supp}
%Jacobians
\newcommand{\inv}[1]{{#1}^{-1}}
\newcommand{\jac}[2]{J_{#1}(#2)}
\newcommand{\djac}[2]{\abs{\det \jac{#1}{#2}}}
% Optimisation
\DeclareMathOperator*{\argmin}{arg\,min}
\DeclareMathOperator*{\argmax}{arg\,max}
% Expectation (optional arg: distribution)
\newcommand{\E}[2][]{\ifthenelse{\equal{#1}{}}{\mathbb{E}\left[#2\right]}{\mathbb{E}_{#1}\left[#2\right]}}
% Prob
\DeclareMathOperator{\BigP}{Pr}
\newcommand{\Prob}[1]{\ensuremath{\BigP\{#1\}}}
% Entropy
\newcommand{\Ent}[1]{\mathbb{H}\left(#1\right)}
% NN
\DeclareMathOperator{\softmax}{softmax}
\DeclareMathOperator{\relu}{relu}
\DeclareMathOperator{\softplus}{softplus}
% Matrix
\DeclareMathOperator{\diag}{diag}
% KL divergence
\DeclareMathOperator{\KullbackLeibler}{KL}
\DeclareMathOperator{\Cat}{Cat}
\newcommand{\KL}[2]{\KullbackLeibler\left(#1\mid\mid #2\right)}
% Normal distribution
\newcommand{\NDist}[2]{\mathcal{N}\left(#1,#2\right)}
% Norm
%\newcommand{\norm}[1]{\lvert \lvert #1 \rvert \rvert}
% Logarithm (optional arg: base)
\newcommand{\loga}[2][]{\ifthenelse{\equal{#1}{}}{\log\left(#2\right)}{\log_{#1}\left(#2\right)}}
% Integral (args: integrand, integration variable -- optional: domain of integration)
\newcommand{\intl}[3][]{\ifthenelse{\equal{#1}{}}{\int
#2 \mathrm{d}#3}{\int_{#1} #2 \mathrm{d}#3}}
% ELBO
\DeclareMathOperator{\ELBO}{ELBO}
% Identity matrix
\DeclareMathOperator{\IMatrix}{I}
% Exponential family
% args: RV, canoncial parameters
% optional: mode ->
% base = full exponential family (default)
% exp = only the exponential
% log = only the term inside the exponential
% dot = only the inner product between sufficient statistics and natural parameters
\newcommand{\expfam}[3][base]{\IfEqCase{#1}{
{base}{h(#2) \exp\left(\eta(#3)^{\top}t(#2) - a(\eta(#3)\right)}
{exp}{\exp\left(\eta(#3)^{\top}t(#2) - a(\eta(#3))\right)}
{log}{\eta(#3)^{\top}t(#2) - a(\eta(#3))}
{dot}{\eta(#3)^{\top}t(#2)}}}
% Bernoulli Distribution
\DeclareMathOperator{\Bernoulli}{Bernoulli}
\newcommand{\BerDist}[1]{\Bernoulli\left(#1\right)}
% Poisson Distribution
\DeclareMathOperator{\Poisson}{Poisson}
\DeclareMathOperator{\vMF}{vMF}
\DeclareMathOperator{\Weibull}{Weibull}
% Categorical Distribution
\DeclareMathOperator{\Categorical}{Categorical}
\newcommand{\CatDist}[1]{\Categorical\left(#1\right)}
% Absolute value
\newcommand{\abs}[1]{\left|#1\right|}