Nov 6 · 1 min read
Hi Deny Rahmalianto,
It’s true the the code implementation does not resemble 1:1 the equation from the text. You can do this by writing:
wNew = np.mean(((signals * wg.T) - (wg_ * w.squeeze().reshape(m, 1))), axis=1)Here you will first calculate the difference and then the mean. The result however is the same because it doesn't make a difference if you first calculate the mean and then multiply or you first multiply and then calculate the mean.
The example below might help:
x = np.array([1, 2, 3, 4, 5, 6, 7, 8, 9, 10])
y = np.array([1, 2, 3])print(np.mean(x * y.squeeze().reshape(3, 1), axis=1))
print(x.mean() * y)
