added all my stuff

This commit is contained in:
2014-11-12 18:39:02 +01:00
parent 0fdcf2f82e
commit 350ee7ca2b
160 changed files with 5869 additions and 253 deletions

Binary file not shown.

View File

@@ -0,0 +1,95 @@
\documentclass[addpoints,10pt]{exam}
\usepackage{url}
\usepackage{color}
\usepackage{hyperref}
\usepackage{graphicx}
\usepackage{amsmath}
\pagestyle{headandfoot}
\runningheadrule
\firstpageheadrule
\firstpageheader{Scientific Computing}{Principal Component Analysis}{Oct 29, 2014}
%\runningheader{Homework 01}{Page \thepage\ of \numpages}{23. October 2014}
\firstpagefooter{}{}{}
\runningfooter{}{}{}
\pointsinmargin
\bracketedpoints
%\printanswers
\shadedsolutions
\usepackage[mediumspace,mediumqspace,Gray]{SIunits} % \ohm, \micro
%%%%% listings %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\usepackage{listings}
\lstset{
basicstyle=\ttfamily,
numbers=left,
showstringspaces=false,
language=Matlab,
breaklines=true,
breakautoindent=true,
columns=flexible,
frame=single,
captionpos=t,
xleftmargin=2em,
xrightmargin=1em,
aboveskip=10pt,
%title=\lstname,
title={\protect\filename@parse{\lstname}\protect\filename@base.\protect\filename@ext}
}
\begin{document}
\sffamily
%%%%%%%%%%%%%% Questions %%%%%%%%%%%%%%%%%%%%%%%%%
\begin{questions}
\question \textbf{Gaussian distribution}
\begin{parts}
\part Use \texttt{randn} to generate 1000000 normally (zero mean, unit variance) distributed random numbers.
\part Plot a properly normalized histogram of these random numbers.
\part Compare the histogram with the probability density of the Gaussian distribution
\[ p(x) = \frac{1}{\sqrt{2\pi\sigma^2}}e^{-\frac{(x-\mu)^2}{2\sigma^2}} \]
where $\mu$ is the mean and $\sigma^2$ is the variance of the Gaussian distribution.
\part Generate Gaussian distributed random numbers with mean $\mu=2$ and
standard deviation $\sigma=\frac{1}{2}$.
\end{parts}
\question \textbf{Covariance and correlation coefficient}
\begin{parts}
\part Generate two vectors $x$ and $z$ with Gausian distributed random numbers.
\part Compute $y$ as a linear combination of $x$ and $z$ according to
\[ y = r \cdot x + \sqrt{1-r^2}\cdot z \]
where $r$ is a parameter $-1 \le r \le 1$.
What does $r$ do?
\part Plot a scatter plot of $y$ versus $x$ for about 10 different values of $r$.
What do you observe?
\part Also compute the covariance matrix and the correlation
coefficient matrix between $x$ and $y$ (functions \texttt{cov} and
\texttt{corrcoef}). How do these matrices look like for different
values of $r$? How do the values of the matrices change if you generate
$x$ and $z$ with larger variances?
\part Do the same analysis (Scatter plot, covariance, and correlation coefficient)
for \[ y = x^2 + 0.5 \cdot z \]
Are $x$ and $y$ really independent?
\end{parts}
\question \textbf{Principal component analysis}
\begin{parts}
\part Generate pairs $(x,y)$ of Gaussian distributed random numbers such
that all $x$ values have zero mean, half of the $y$ values have mean $+d$
and the other half mean $-d$, with $d \ge0$.
\part Plot scatter plots of the pairs $(x,y)$ for $d=0$, 1, 2, 3, 4 and 5.
Also plot a histogram of the $x$ values.
\part Apply PCA on the data and plot a histogram of the data projected onto
the PCA axis with the largest eigenvalue.
What do you observe?
\end{parts}
\end{questions}
\end{document}

Binary file not shown.

View File

@@ -0,0 +1,205 @@
\documentclass[addpoints,10pt]{exam}
\usepackage{url}
\usepackage{color}
\usepackage{hyperref}
\usepackage{graphicx}
\usepackage{amsmath}
\pagestyle{headandfoot}
\runningheadrule
\firstpageheadrule
\firstpageheader{Scientific Computing}{Matrix multiplication}{Oct 28, 2014}
%\runningheader{Homework 01}{Page \thepage\ of \numpages}{23. October 2014}
\firstpagefooter{}{}{}
\runningfooter{}{}{}
\pointsinmargin
\bracketedpoints
%\printanswers
\shadedsolutions
\usepackage[mediumspace,mediumqspace,Gray]{SIunits} % \ohm, \micro
%%%%% listings %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\usepackage{listings}
\lstset{
basicstyle=\ttfamily,
numbers=left,
showstringspaces=false,
language=Matlab,
breaklines=true,
breakautoindent=true,
columns=flexible,
frame=single,
captionpos=t,
xleftmargin=2em,
xrightmargin=1em,
aboveskip=10pt,
%title=\lstname,
title={\protect\filename@parse{\lstname}\protect\filename@base.\protect\filename@ext}
}
\begin{document}
\sffamily
%%%%%%%%%%%%%% Questions %%%%%%%%%%%%%%%%%%%%%%%%%
\begin{questions}
\question \textbf{Matrix multiplication}
Calculate the results of the following matrix multiplications and
confirm the result using matlab.
\[ \begin{pmatrix} 2 \\ -4 \\ -1 \end{pmatrix} \cdot
\begin{pmatrix} 3 & -4 & -4 \end{pmatrix} = \]
\[ \begin{pmatrix} 3 & -3 & -1 \end{pmatrix} \cdot
\begin{pmatrix} 2 \\ 3 \\ 0 \end{pmatrix} = \]
\[ \begin{pmatrix} 4 & -1 & 2 \\ -1 & 3 & 1 \\ 4 & -2 & 1 \\ 4 & -3 & -2 \end{pmatrix} \cdot
\begin{pmatrix} -2 & -2 & 0 & -3 \\ 3 & -2 & 1 & 0 \\ 1 & -2 & -4 & 0 \end{pmatrix} = \]
\[ \begin{pmatrix} 3 & 1 \\ 1 & 4 \end{pmatrix} \cdot
\begin{pmatrix} 0 & -3 & 4 & 1 \\ -2 & -1 & -2 & -3 \\ -3 & 1 & -2 & -3 \end{pmatrix} = \]
\[ \begin{pmatrix} 1 & 1 & -4 \end{pmatrix} \cdot
\begin{pmatrix} -1 \\ 2 \end{pmatrix} = \]
\[ \begin{pmatrix} 3 & 1 & -2 \\ 2 & 1 & 3 \\ 1 & 1 & 2 \end{pmatrix} \cdot
\begin{pmatrix} 2 & 2 \\ -3 & 3 \\ -4 & 1 \end{pmatrix} = \]
\[ \begin{pmatrix} 3 \\ 2 \end{pmatrix} \cdot
\begin{pmatrix} -3 & 2 & -4 & 1 \end{pmatrix} = \]
\[ \begin{pmatrix} -1 \\ -4 \\ -1 \end{pmatrix} \cdot
\begin{pmatrix} 0 & -4 & 1 \end{pmatrix} = \]
\[ \begin{pmatrix} 4 & -2 & -2 & -4 \end{pmatrix} \cdot
\begin{pmatrix} 2 \\ 2 \\ 1 \\ -1 \end{pmatrix} = \]
\[ \begin{pmatrix} -2 & -3 & -4 \\ 1 & 3 & 2 \\ -4 & -2 & 1 \end{pmatrix} \cdot
\begin{pmatrix} 1 & 2 & -2 & 4 \\ 3 & -1 & 1 & -1 \\ -3 & 2 & -1 & 2 \end{pmatrix} = \]
\[ \begin{pmatrix} 2 & -4 & 4 & 4 \\ -3 & 3 & 2 & 1 \end{pmatrix} \cdot
\begin{pmatrix} 0 & 3 & 4 & -2 \\ -4 & -2 & -1 & 0 \\ 1 & 2 & -4 & -4 \\ 3 & 2 & -2 & -4 \end{pmatrix} = \]
\[ \begin{pmatrix} 3 & 1 & -2 & -2 \end{pmatrix} \cdot
\begin{pmatrix} -4 \\ 3 \\ -2 \\ 4 \end{pmatrix} = \]
\[ \begin{pmatrix} -1 & 3 & 4 \end{pmatrix} \cdot
\begin{pmatrix} -1 \\ 4 \\ -3 \end{pmatrix} = \]
\[ \begin{pmatrix} 1 & -4 & 3 & 3 \end{pmatrix} \cdot
\begin{pmatrix} 1 \\ 0 \\ -4 \\ -1 \end{pmatrix} = \]
\[ \begin{pmatrix} -4 & -4 & -3 \\ -2 & -2 & 4 \\ -3 & 4 & -3 \end{pmatrix} \cdot
\begin{pmatrix} 0 & 3 & -4 & 4 \\ -1 & -2 & -3 & 1 \\ 1 & -2 & 2 & 0 \end{pmatrix} = \]
\[ \begin{pmatrix} -3 & 0 & 4 & 1 \\ 0 & 1 & 1 & 4 \end{pmatrix} \cdot
\begin{pmatrix} -4 & 3 & 1 & 4 \\ 1 & -4 & 1 & -3 \\ -4 & 0 & -4 & -4 \\ 1 & -2 & 4 & 4 \end{pmatrix} = \]
\[ \begin{pmatrix} 4 \\ 3 \\ 4 \\ -2 \end{pmatrix} \cdot
\begin{pmatrix} 2 & 4 & 3 & 3 \end{pmatrix} = \]
\[ \begin{pmatrix} 1 & 2 & 0 & 3 \end{pmatrix} \cdot
\begin{pmatrix} -3 \\ 1 \\ 1 \end{pmatrix} = \]
\[ \begin{pmatrix} -4 & 0 & -1 & 3 \\ 0 & -4 & 3 & -3 \end{pmatrix} \cdot
\begin{pmatrix} -1 & -4 & -1 \\ 3 & 2 & 0 \\ -2 & 3 & -2 \\ 1 & 2 & -2 \end{pmatrix} = \]
\[ \begin{pmatrix} 2 & 0 & 3 \\ 1 & -4 & -1 \\ 3 & 0 & -2 \end{pmatrix} \cdot
\begin{pmatrix} 0 & 2 & -1 & -2 \\ -1 & -1 & -3 & 4 \\ 2 & 4 & -4 & 1 \end{pmatrix} = \]
\[ \begin{pmatrix} -1 & 4 \end{pmatrix} \cdot
\begin{pmatrix} 0 \\ 1 \end{pmatrix} = \]
\[ \begin{pmatrix} -4 & 3 \\ -4 & 0 \\ -2 & -2 \end{pmatrix} \cdot
\begin{pmatrix} 0 & 1 & -4 & 2 \\ 2 & 3 & -2 & -1 \end{pmatrix} = \]
\[ \begin{pmatrix} -2 & -1 \end{pmatrix} \cdot
\begin{pmatrix} 1 \\ -2 \end{pmatrix} = \]
\[ \begin{pmatrix} -2 & 2 & -2 & -3 \\ 2 & -4 & -2 & 2 \\ 0 & 2 & -2 & -2 \\ 1 & -2 & -2 & -2 \end{pmatrix} \cdot
\begin{pmatrix} 1 & -2 & 2 \\ -4 & -2 & -2 \\ 3 & 1 & 4 \\ -4 & 1 & -2 \end{pmatrix} = \]
\[ \begin{pmatrix} -1 & -3 & 0 & -1 \\ 4 & -2 & 1 & 2 \end{pmatrix} \cdot
\begin{pmatrix} -3 & -4 \\ -4 & 0 \end{pmatrix} = \]
\[ \begin{pmatrix} -1 & 1 & -2 \\ -2 & 2 & -4 \\ 1 & -2 & -2 \end{pmatrix} \cdot
\begin{pmatrix} -1 & 2 & -4 \\ 1 & 3 & 0 \\ 1 & 4 & -4 \end{pmatrix} = \]
\[ \begin{pmatrix} -3 & 3 \\ -3 & 2 \end{pmatrix} \cdot
\begin{pmatrix} 2 & -3 \\ -2 & -4 \end{pmatrix} = \]
\[ \begin{pmatrix} 1 & 1 & -3 \end{pmatrix} \cdot
\begin{pmatrix} -1 \\ -2 \\ 3 \end{pmatrix} = \]
\[ \begin{pmatrix} -4 & 2 & 1 \\ 4 & 0 & -2 \\ 2 & 3 & -3 \\ -2 & -2 & -2 \end{pmatrix} \cdot
\begin{pmatrix} -1 & 2 & 0 & -2 \\ 2 & -2 & 0 & -1 \\ -4 & 3 & -3 & 4 \end{pmatrix} = \]
\[ \begin{pmatrix} -2 & -4 & 2 & 4 \\ 3 & -3 & 2 & 1 \end{pmatrix} \cdot
\begin{pmatrix} 0 & 4 & -1 & -4 \\ 2 & 3 & -4 & -1 \\ 3 & 2 & -2 & 4 \end{pmatrix} = \]
\[ \begin{pmatrix} -3 & -2 & -1 & -3 \end{pmatrix} \cdot
\begin{pmatrix} 2 \\ -2 \\ 3 \\ -2 \end{pmatrix} = \]
\[ \begin{pmatrix} 4 & 4 & 2 & 3 \end{pmatrix} \cdot
\begin{pmatrix} 3 \\ 3 \\ -2 \\ 1 \end{pmatrix} = \]
\[ \begin{pmatrix} 3 & 2 & -2 \end{pmatrix} \cdot
\begin{pmatrix} 2 \\ 4 \\ 3 \end{pmatrix} = \]
\[ \begin{pmatrix} 2 & -1 & 0 & -2 \\ 0 & -4 & -3 & -1 \end{pmatrix} \cdot
\begin{pmatrix} 4 & -3 & 2 & 4 \\ -3 & -4 & 1 & 1 \\ 1 & 3 & -2 & 3 \\ -1 & -2 & 3 & 0 \end{pmatrix} = \]
\[ \begin{pmatrix} -3 & -3 & 3 & 2 \\ 2 & 2 & -3 & 1 \end{pmatrix} \cdot
\begin{pmatrix} 0 & 1 \\ 4 & 2 \\ -3 & -1 \\ -3 & 4 \end{pmatrix} = \]
\[ \begin{pmatrix} -4 & -3 \end{pmatrix} \cdot
\begin{pmatrix} -2 \\ 3 \\ 4 \end{pmatrix} = \]
\[ \begin{pmatrix} 4 & 4 \end{pmatrix} \cdot
\begin{pmatrix} 1 \\ 4 \\ -1 \end{pmatrix} = \]
\[ \begin{pmatrix} 1 & -2 & 3 \end{pmatrix} \cdot
\begin{pmatrix} 3 \\ 1 \\ 2 \end{pmatrix} = \]
\[ \begin{pmatrix} -3 & 2 \end{pmatrix} \cdot
\begin{pmatrix} -1 \\ 1 \end{pmatrix} = \]
\[ \begin{pmatrix} -2 & -4 & -4 & 0 \\ 0 & 3 & 4 & -4 \\ 4 & 2 & -2 & -4 \\ 0 & 0 & 4 & -1 \end{pmatrix} \cdot
\begin{pmatrix} 0 & -1 \\ -1 & 1 \\ -4 & -3 \\ 2 & 1 \end{pmatrix} = \]
\[ \begin{pmatrix} -3 \\ 3 \\ -3 \\ -4 \end{pmatrix} \cdot
\begin{pmatrix} 2 & 4 & -2 & 1 \end{pmatrix} = \]
\[ \begin{pmatrix} 2 \\ 0 \end{pmatrix} \cdot
\begin{pmatrix} -1 & -3 & -2 & 2 \end{pmatrix} = \]
\[ \begin{pmatrix} 0 & -4 & -4 & 4 \end{pmatrix} \cdot
\begin{pmatrix} 1 \\ 4 \\ 0 \\ 4 \end{pmatrix} = \]
\[ \begin{pmatrix} -3 & -1 \\ -3 & -1 \end{pmatrix} \cdot
\begin{pmatrix} 0 & -3 & 3 & -2 \\ -4 & 1 & -1 & 4 \end{pmatrix} = \]
\[ \begin{pmatrix} 4 & 0 \\ -1 & 4 \\ 1 & -3 \end{pmatrix} \cdot
\begin{pmatrix} -4 & -4 \\ -4 & 2 \end{pmatrix} = \]
\[ \begin{pmatrix} -1 \\ 3 \\ 2 \\ 4 \end{pmatrix} \cdot
\begin{pmatrix} 0 & -1 & 0 & 0 \end{pmatrix} = \]
\[ \begin{pmatrix} 3 \\ -2 \\ 2 \\ 3 \end{pmatrix} \cdot
\begin{pmatrix} -2 & -3 & -4 & 2 \end{pmatrix} = \]
\[ \begin{pmatrix} 2 & -2 & -4 & 4 \\ 0 & 1 & -3 & -2 \\ -1 & 3 & 0 & -2 \end{pmatrix} \cdot
\begin{pmatrix} -4 & 1 \\ -4 & 3 \end{pmatrix} = \]
\[ \begin{pmatrix} -4 & -1 & 3 \end{pmatrix} \cdot
\begin{pmatrix} -4 \\ -3 \\ 3 \end{pmatrix} = \]
\question \textbf{Automatic generation of exercises}
Write some matlab code that generates exercises like this one automatically! :-)
\end{questions}
\end{document}