I just realized this forum existed, posted my question on the wrong forum.
Sorry about the formatting, please don't hesitate to ask if any part of this post is unclear. This is my first post.
I'm trying to implement a simulation of an ANC system with python, using this model here, but that's not the main point. My simulation keeps diverging, so I'm trying to figure out if it's my system is unstable or did I implement the NLMS algorithm wrong. Below is my code for the NLMS update. I'm using a source from Mathworks here.
x is input vector--------------------------------------------dimension(N * 1)
error is (desired vector - NLMS prediction)---------dimension(N * 1)
w_prev is the previous iteration's weight vector---dimension(1 * m)
def lms_update(x,error,w_prev,mu):
ep = 0
w_prev = np.array(w_prev)
error = np.array(error)
x_normal = np.dot(np.conjugate(x),np.linalg.inv((ep+np.dot(np.transpose(np.conjugate(x)),x))))
w_update = w_prev + 2*mu*np.dot(error,x_normal)
w_update = w_update.tolist()
return w_update
then from above dimensions, after applying the update formula,
w(n)=αw(n−1)+f(u(n),e(n),μ)
and f(u(n),e(n),μ)=μe(n)u'(n)
the update would be a 1 * 1 constant, and the weight would all be updated with the same value, which doesn't make too much sense to me.
So I adjust the input vector x into a (N * m) matrix, using vectors from current and previous iterations, so I can get the update to be a (1 * m) matrix. But I'm not sure if this is the correct way. From what I gathered from papers and google searches, nothing pops up indicating dimensions of the input. But I did implement a gradient descent algorithm before which input is a matrix, not a vector.