Skip to content

Commit

Permalink
Solve Yule Walker equation
Browse files Browse the repository at this point in the history
  • Loading branch information
aaaakshat committed Nov 16, 2021
1 parent 1944f22 commit 6a737a5
Showing 1 changed file with 25 additions and 0 deletions.
25 changes: 25 additions & 0 deletions ch10.r
Original file line number Diff line number Diff line change
Expand Up @@ -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)

0 comments on commit 6a737a5

Please sign in to comment.