Debian Codegraph @

texmf-dist/doc/latex/thucoursework/iihw.tex

raw
1 % Sample tex file for usage of iidef.sty
2 % Homework template for Inference and Information
3 % UPDATE: October 12, 2017 by Xiangxiang
4 % UPDATE: 22/03/2018 by zhaofeng-shu33
5 \documentclass[a4paper]{article}
6 \usepackage[T1]{fontenc}
7 \usepackage{amsmath, amssymb, amsthm}
8 % amsmath: equation*, amssymb: mathbb, amsthm: proof
9 \usepackage{moreenum}
10 \usepackage{mathtools}
11 \usepackage{url}
12 \usepackage{graphicx}
13 \usepackage{subcaption}
14 \usepackage{booktabs} % toprule
15 \usepackage[mathcal]{eucal}
16 \usepackage{dsfont}
17
18 \usepackage[numbered,framed]{matlab-prettifier}
19 \lstset{
20 style = Matlab-editor,
21 captionpos =b,
22 basicstyle = \mlttfamily,
23 escapechar = ",
24 mlshowsectionrules = true,
25 }
26
27 \usepackage[thehwcnt = 6]{iidef}
28 \thecourseinstitute{Tsinghua-Berkeley Shenzhen Institute}
29 \thecoursename{Information Inference}
30 \theterm{Fall 2017}
31 \hwname{Coursework}
32 \begin{document}
33 \courseheader
34 \name{YOUR NAME}
35 \rule{\textwidth}{1pt}
36 \begin{itemize}
37 \item {\bf Acknowledgments: \/}
38 This template takes some materials from course CSE 547/Stat 548, University of Washington: \small{\url{https://courses.cs.washington.edu/courses/cse547/17sp/index.html}}.
39
40 If you refer to other materials in your homework, please list here.
41 \item {\bf Collaborators: \/}
42 I finish this template by myself. If you finish your homework all by yourself, make a similar statement. If you get help from others in finishing your homework, state like this:
43 \begin{itemize}
44 \item 1.2 (b) was solved with the help from \underline{\hspace{3em}}.
45 \item Discussion with \underline{\hspace{3em}} helped me finishing 1.3.
46 \end{itemize}
47 \end{itemize}
48 \rule{\textwidth}{1pt}
49
50 \vspace{2em}
51
52 You may use \texttt{enumerate} to generate answers for each question:
53
54 \begin{enumerate}
55 \setlength{\itemsep}{3\parskip}
56
57 \item Type of commonly used notations. Use another \texttt{enumerate} to start generate answers for sub-questions:
58 \begin{enumerate}
59 \item Use \verb|$ $| to get an inline equation: $\Prob(A) = \E[\1_A(\omega)]$.
60 \item Use \texttt{equation} to have equation in display math mode:
61 \begin{equation}
62 \frac{a + b}{2} \geq \sqrt{ab}
63 \label{eq:1}
64 \end{equation}
65
66 \item Use \verb|\eqref| to get reference for equations: \eqref{eq:1} holds when $a\geq 0, b\geq 0$.
67
68 \item Now we would introduce some commonly used notations:
69 \begin{enumerate}
70 \item Use \verb|\mathbb{P}, \mathbb{R}, \mathbb{E}| to type $\mathbb{P}, \mathbb{R}, \mathbb{E}$.
71 \item Use \verb|\mathcal{A}, \mathcal{X}, \mathcal{Y}, \mathcal{N}| to type $\mathcal{A}, \mathcal{X}, \mathcal{Y}, \mathcal{N}$.
72 \item Use \verb|\underline{x}, \underline{y}| to type vectors $\underline{x}, \underline{y}$.
73 \item Use \verb|\mathsf{x}, \mathsf{y}, \mathsf{z}| to type random variables $\rvx, \rvy, \rvz$. For simplicity, I have defined several macros so you could simply type \verb|\rvx, \rvy, \rvz|. Don't forget \verb|$ $|!
74 \item Thanks to these macros, we could have $\reals, \E[\rvx], \Var(\rvy), \Prob(A), \independent, \1$ by typing \verb|\reals, \E[\rvx], \Var(\rvy), \Prob(A),\independent,| \verb|\1|.
75 \item Now you can use \verb|\ux, \uy, \uz| to type vectors $\ux, \uy, \uz$, and use \verb|\urvx, \urvy, \urvz| to type random vectors $\urvx, \urvy, \urvz$.
76 \item Remember that $P_{\rvx|\rvy}(x|y) \defas \Prob(\rvx = x|\rvy = y)$.
77 \begin{enumerate}
78 \item Writing $\Prob(x)$ is wrong. $\Prob$ should only operate on events.
79 \item $\rvx$ is a random variable, while $x$ is a real number.
80 \end{enumerate}
81
82 \end{enumerate}
83 \item You may find \url{https://en.wikibooks.org/wiki/LaTeX} useful.
84 \item Writing \LaTeX\ online may be easier for beginners:
85 \begin{enumerate}
86 \item ShareLaTeX: \url{https://www.sharelatex.com/}.
87 \item Overleaf: \url{https://www.overleaf.com/}.
88 \end{enumerate}
89 \end{enumerate}
90 \item You may need aligned equations for your homework, here are several examples:
91
92 Total propability rule:
93 \begin{equation*}
94 \begin{aligned}
95 \Prob(\rvx = x)
96 &= \sum_{y \in \mathcal{Y}} \Prob(\rvx = x, \rvy = y)\\
97 &= \sum_{y \in \mathcal{Y}} \Prob(\rvx = x| \rvy = y) \Prob(\rvy = y),\\
98 \end{aligned}
99 \end{equation*}
100 or
101 \begin{equation*}
102 \begin{aligned}
103 &\quad~ P_{\rvx}(x)\\
104 &= \sum_{y \in \mathcal{Y}} P_{\rvx\rvy}(x,y)\\
105 &= \sum_{y \in \mathcal{Y}} P_{\rvx|\rvy}(x|y)P_{\rvy}(y).\\
106 \end{aligned}
107 \end{equation*}
108 Indicator function:
109 \begin{equation*}
110 \1_A(\omega)=
111 \left\{
112 \begin{aligned}
113 1, &\quad\text{if}~ \omega \in A,\\
114 0, &\quad\text{if}~ \omega \notin A.
115 \end{aligned}
116 \right.
117 \end{equation*}
118
119 \item You may need to add figure and source codes in your homework. Figure \ref{fig:1} is an example that compares the empirical distribution (histogram) and probability density function of the Gaussian random variable.
120 \begin{figure}[htbp]
121 \centering
122 \includegraphics[width = 0.8\textwidth]{pdf_normal.pdf}
123 \caption{Gaussian PDF and histogram of samples}
124 \label{fig:1}
125 \end{figure}
126
127 The source code to plot Figure \ref{fig:1} could be found in Appendix \ref{sec:a:code}. Here are the core codes:
128 \lstinputlisting[firstline=4,lastline=4, firstnumber=4]{matlabscript.m}
129 \lstinputlisting[firstline=6,lastline=7, firstnumber=6]{matlabscript.m}
130 To understand line 6, note that if we have $n$ samples of $\rvx$ denoted by $x^{(i)}, i = 1, 2, \cdots, n$, then the probability density function $p_{\rvx}$ could be estimated as
131 \begin{equation*}
132 \begin{aligned}
133 p_{\rvx}(x_0) &= \left.\frac{\mathrm{d}}{\mathrm{d}x} \Prob(\rvx \leq x) \right|_{x = x_0} \\
134 &\approx \frac{\Prob(x_0 - \Delta x < \rvx \leq x_0)}{\Delta x}\\
135 &\approx \frac{1}{n\Delta x} \sum_{i = 1}^n \1_{x^{(i)} \in (x_0 - \Delta x, x_0]}.
136 \end{aligned}
137 \end{equation*}
138
139 \item An example of hypothesis testing:
140 \begin{equation*}
141 \log \frac{\Prob(\rvH = H_1|\rvy = y)}{\Prob(\rvH = H_0|\rvy = y)}
142 \mathop{\gtreqless}_{\hat{\rvH} = H_0}^{\hat{\rvH} = H_1} \gamma
143 \end{equation*}
144
145 \end{enumerate}
146
147
148 \newpage
149
150 \appendix
151 \section{Source code}
152 \label{sec:a:code}
153 % \lstlistoflistings
154 Source code for plotting Figure \ref{fig:1} is shown as follows.
155 \lstinputlisting[caption=FigurePlot]{matlabscript.m}
156
157 \end{document}
158 %%% Local Variables:
159 %%% mode: latex
160 %%% TeX-master: t
161 %%% End: