Skip to content

Commit

Permalink
Complete chapter 10.5
Browse files Browse the repository at this point in the history
  • Loading branch information
aaaakshat committed Nov 16, 2021
1 parent 1ee487b commit 05591a8
Showing 1 changed file with 29 additions and 0 deletions.
29 changes: 29 additions & 0 deletions ch10.r
Original file line number Diff line number Diff line change
Expand Up @@ -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")

0 comments on commit 05591a8

Please sign in to comment.