From fd7215c8e39b1cb983821c0a96bb860c9e1cccf3 Mon Sep 17 00:00:00 2001 From: aaaakshat <33050725+aaaakshat@users.noreply.github.com> Date: Wed, 10 Nov 2021 16:14:55 -0500 Subject: [PATCH] Finish examples 10.11 --- ch10.r | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/ch10.r b/ch10.r index 16e0fa9..6763fb3 100644 --- a/ch10.r +++ b/ch10.r @@ -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")