Skip to content

Commit

Permalink
Finish examples 10.11
Browse files Browse the repository at this point in the history
  • Loading branch information
aaaakshat committed Nov 16, 2021
1 parent f3d92c3 commit fd7215c
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions ch10.r
Original file line number Diff line number Diff line change
Expand Up @@ -58,5 +58,24 @@ for (i in 1:ncol(x)) {
}
stem(t, 1/(t+1), col="darkred", lwd=2, pch=1, type="o")

## Example 10.11

# R code for Example 10.11: Plot the time function
t = seq(-2, 2, len = 1000)
x = matrix(0, 1000, 20)

for (i in 1:20) {
x[,i] = runif(1) * cos(2*pi*t)
}

matplot(t, x, lwd=2, col="gray", type="l", lty="solid", xaxp=c(-2,2, 8))
grid()
lines(t, 0.5*cos(2*pi*t), lwd=5, col="darkred")
points(numeric(20), x[501,], lwd=2, col="darkorange")
points(numeric(20) + 0.5, x[626,], lwd=2, col="blue", pch=4)

# R code for Example 10.11: Plot the autocorrelation function
t = seq(-1, 1, len=1000)
R = (1/3)*outer(cos(2*pi*t), cos(2*pi*t))
image(t, t, R, col=topo.colors(255), xlab="t_1", ylab="t_2")

0 comments on commit fd7215c

Please sign in to comment.