# matern.spec: Spectrum of the Matern covariance function. In spate: Spatio-Temporal Modeling of Large Data Using a Spectral SPDE Approach

## Description

Spectrum of the Matern covariance function. Note that the spectrum is renormalized, by dividing with the sum over all frequencies so that they sum to one, so that σ^2 is the marginal variance no matter how many wavenumbers are included.

## Usage

 `1` ```matern.spec(wave, n, ns=4, rho0, sigma2, nu = 1, norm = TRUE) ```

## Arguments

 `wave` Spatial wavenumbers. `n` Number of grid points on each axis. n x n is the total number of spatial points. `ns` Integer indicating the number of cosine-only terms. Maximally this is 4. `rho0` Range parameter. `sigma2` Marginal variance parameter. `nu` Smoothness parameter of the Matern covariance function. By default this equals 1 corresponding to the Whittle covariance function. `norm` logical; if 'TRUE' the spectrum is multiplied by n*n so that after applying the real Fourier transform 'real.FFT' one has the correct normalization.

## Details

The Matern covariance function is of the form

σ^2 2^(1-ν) Γ(ν)^{-1} (d/ρ_0)^{ν} K_{ν}(d/ρ_0)

with 'd' being the Euclidean distance between two points and K_nu(.) a modified Bessel function. Its spectrum is given by

2^{ν-1} ν ((1/ρ_0)^(2ν)) (π*((1/ρ_0)^2 + w)^(ν + 1))^{-1}

where 'w' is a spatial wavenumber.

## Value

Vector with the spectrum of the Matern covariance function.

Fabio Sigrist

## Examples

 ```1 2 3 4 5``` ```n <- 100 spec <- matern.spec(wave=spate.init(n=n,T=1)\$wave,n=n,rho0=0.05,sigma2=1,norm=TRUE) sim <- real.fft(sqrt(spec)*rnorm(n*n),n=n,inv=FALSE) image(1:n,1:n,matrix(sim,nrow=n),main="Sample from a Gaussian process with Matern covariance function",xlab="",ylab="",col=cols()) ```

### Example output

```Loading required package: mvtnorm