From 05591a8ca0e550221703ab80bbcc2eb4a6d8db7e Mon Sep 17 00:00:00 2001 From: aaaakshat <33050725+aaaakshat@users.noreply.github.com> Date: Thu, 11 Nov 2021 16:08:47 -0500 Subject: [PATCH] Complete chapter 10.5 --- ch10.r | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/ch10.r b/ch10.r index d83b5db..bf15c6d 100644 --- a/ch10.r +++ b/ch10.r @@ -128,3 +128,32 @@ for (i in 1:N) { plot(xc[1,], type="l", lwd=2, col="darkblue") lines(xc[2,], lwd=2) +############# +# Chapter 10.5 Wide sense stationary processes + +## Example 10.15 + +# R code for Example 10.15 +t = seq(-10, 10, by=0.001) +L = length(t) +X = rnorm(L) +h = 10 * sapply((1 - abs(t)), max, 0) / 1000 +Y = convolve(X, h, type=c("circular")) + +# Figure 1 +plot(t, X, lwd=1, col="gray", type="l") +grid() +legend(6, 3.8, legend=c("X(t)", "μ_x(t)", "Y(t)", "μ_y(t)"), col=c("gray", "black", "darkorange", "yellow"), lty=c(1, 1, 1, 3), lwd=c(1, 4, 3, 4), bg="white") +abline(h=0, lwd=4, lty=1, col="yellow") +lines(t, Y, lwd=3, col="darkorange") +abline(h=0, lwd=4, lty=3) + +# Figure 2 +h2 = convolve(h, h, type="open") +Rx = numeric(40001) +Rx[20001] = 0.2 +plot(seq(-20, 20, by=0.001), Rx, lwd=2, col="gray", type="l", xlim=c(-2,2), ylim=c(-0.05, 0.2)) +grid() +legend(-2, 0.19, legend=c("R_x(t)", "R_y(t)"), col=c("gray", "darkorange"), lty=1:1, lwd=2) +lines(seq(-20, 20, by=0.001), h2, lwd=2, col="darkorange") +