Thursday, August 23, 2012

Gaussian white noise R code


The above graph denotes a gaussian white noise that was generated using 100 random numbers in R.

rnorm : Used to generate a random normal distribution.
ACF : Autocorrelation function display the cross-correlation of a signal with itself. In the above graph you can see none of the lags of the signal are dependent on the signal itself. That supports the theory that this is a gaussian white noise.
Also, notice in the time series graph above, the signal looks mean reverting and the volatility appears to be constant. That proves that the signal is a covariance stationary process.

Below is the code that generate the graph above:
set.seed(12345)
gwn <- rnorm(100)
layout(matrix(1:4, ncol = 2, nrow = 2))
plot.ts(gwn, xlab = "", ylab = "")
abline(h = 0, col = "red")
acf(gwn, main = "ACF")
qqnorm(gwn)
pacf(gwn, main = "PACF")
view raw gwn.r hosted with ❤ by GitHub

No comments: