# Homework 1¶

## Due: end of week 3¶

### Probablity and Karhunen-Loeve expansion¶

Note: The codes for this homework are available in the public Bitbucket repository: https://bitbucket.org/motamed/uq2017 within the subdirectory hw1. You can clone the whole repository to your local repository, for instance by typing in a shell terminal:

\$ git clone https://motamed@bitbucket.org/motamed/uq2017.git


Description: In this assignment you will numerically study the Karhunen-Loeve (KL) decomposition of a second-order weakly stationary Gaussian field on a two-dimensional rectangular domain $$D = [0,20] \times [0,10] \subset {\mathbb R}^2$$.

Let $$(\Omega, \Sigma, P)$$ be a complete probability space. Consider a stationary Gaussian random field $$a({\bf x},\omega): D \times \Omega \rightarrow {\mathbb R}$$ and the following three covariance functions:

• Exponential covariance model: $$C_1 ({\bf x},{\bf x}') = \sigma_a^2 \, \exp(\frac{- || {\bf x} - {\bf x}' ||}{L_c})$$;
• Matern covariance model: $$C_2 ({\bf x},{\bf x}') = \sigma_a^2 \, \frac{1}{\Gamma(\nu) 2^{\nu-1}} (\sqrt{2 \nu} \frac{|| {\bf x} - {\bf x}' ||}{L_c})^{\nu} \, K_{\nu}(\sqrt{2 \nu} \frac{|| {\bf x} - {\bf x}' ||}{L_c})$$;
• Squared exponential covariance model: $$C_3 ({\bf x},{\bf x}') = ({\bf x},{\bf x}') = \sigma_a^2 \, \exp(\frac{- || {\bf x} - {\bf x}' ||^2}{2 \, L_c^2})$$.

Here, $$\sigma_a^2 = C_j({\bf x},{\bf x})$$, with $$j=1,2,3$$, is the constant variance of the field, $$L_c$$ is the correlation length of the field, $$K_{\nu}$$ is the modified Bessel function of the second kind, and $$\nu$$ is a positive smoothing parameter.

The $$N_{\text{KL}}$$ -term truncated KL approximation of the random field reads

$$a_{N_{\text{KL}}} ({\bf x},\omega) = \mu_a + \sum_{i=1}^{N_{\text{KL}}} \sqrt{\lambda_i} \, b_i({\bf x}) \, y_i(\omega),$$

where $$\mu_a = {\mathbb E}[a]$$ is the constant mean of the field, ($$\lambda_i, b_i$$) are the eigenpairs corresponding to the covariance eigenvalue problem, and $$y_i \sim {\mathcal N}(0,1)$$, with $$i=1,2,\dotsc,N_{\text{KL}}$$, are independent standard Gaussian random variables. In this assignment we will set $$\mu_a = 1$$ and $$\sigma_a = 1.5$$.

1. Download MATLAB files KL_Gaussian.m and Matern_cov.m from the subdirectory hw1 in the public Bitbucket repository: https://bitbucket.org/motamed/uq2017. The domain is first discretized into $$N \times M$$ square elements, where $$N=40$$ and $$M=20$$ are the number of elements in $$x_1$$ and $$x_2$$ directions, respectively. You will need to modify KL_Gaussian.m for the following tasks.
2. Let $$L_c =3$$ and $$\nu =1$$. Plot the eigenvalues $$\lambda_i$$ for the three covariances in the same figure in logarithmic scale. Comment on the rate of eigenvalues decay.
3. Let $$L_c =3$$ and nu =1. How many terms $$N_{KL}$$ are needed to preserve $$90\%$$ of the variance for each covariance model?
4. Let $$\nu =1$$, and consider a set of different correlation lengths $$L_c = [2, 3, 4, \dotsc, 20]$$. Plot the number of terms $$N_{KL}$$ needed to preserve $$95\%$$ of the variance versus $$L_c$$ for each covariance model in the same figure. Compare the models and comment on the results.
5. Let $$L_c =2$$, and consider a set of different smoothness parameters $$\nu = [0.5, 1, 1.5, 2, \dotsc, 10]$$. Plot $$N_{KL}$$ needed to preserve $$95\%$$ of the variance versus $$\nu$$ only for the Matern model. Comment on the result.
6. Let $$L_c =2$$ and $$\nu = 2$$. For each covariance model, use KL expansion and generate and plot one realization of the random field. You will have three plots, each representing one realization of the field with one of the covariance models. This will give you an idea how random fields with different covariance models look like.