diff --git a/ch10.r b/ch10.r index bf15c6d..24a106f 100644 --- a/ch10.r +++ b/ch10.r @@ -157,3 +157,28 @@ 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") +############# +# Chapter 10.6 Optimal linear filter + +## Solve the Yule Walker equation + +# R code to solve the Yule Walker Equation + +y = scan("./ch10_LPC_data.txt") +K = 10 +N = 320 +y_corr = ccf(y, y, lag.max=2*length(y)-1)$acf +R = toeplitz(y_corr[N + 1:K-1]) +lhs = y_corr[N + 1:K] +h = solve(R, lhs) + +# Figure 1 +plot(y, lwd = 4, col="blue", type="l") +grid() +legend(10, 0.1, legend=c("Y[n]"), col=c("blue"), lty=1:1, lwd=4) + +# Figure 2 +plot(y_corr, lwd = 4, type="l") +grid() +legend(10, 0.9, legend=c("R_y[k]"), col=c("black"), lty=1:1, lwd=4) +