Online centered normalized Least-mean-square (OCNLMS)

New in version 1.2.0.

The online-centered normalized least-mean-square (OCNLMS) adaptive filter (proposed in https://doi.org/10.14311/nnw.2021.31.019) is an extension of the popular NLMS adaptive filter (Normalized Least-mean-square (NLMS)).

The OCNLMS filter can be created as follows

>>> import padasip as pa
>>> pa.filters.FilterOCNLMS(n, mem=100)

where n is the size (number of taps) of the filter.

Content of this page:

See also

Adaptive Filters

Algorithm Explanation

The OCNLMS is extension of NLMS filter. See Normalized Least-mean-square (NLMS) for explanation of the algorithm behind. As an extension of the normalized least mean square (NLMS), the OCNLMS algorithm features an approach of online input centering according to the introduced filter memory. This key feature can compensate the effect of concept drift in data streams, because such a centering makes the filter independent of the nonzero mean value of signal.

Minimal Working Examples

Exampleof an unknown system identification from mesaured data follows. The memory size mem is defined during the construction of the filter.

import numpy as np
import matplotlib.pylab as plt
import padasip as pa

# creation of data
N = 500
x = np.random.normal(0, 1, (N, 4)) + 121 # input matrix with offset
v = np.random.normal(0, 0.1, N) # noise
d = 2*x[:,0] + 0.1*x[:,1] - 4*x[:,2] + 0.5*x[:,3] + v # target

# identification, memory is set to 100 samples
f = pa.filters.FilterOCNLMS(n=4, mu=0.1, w="random", mem=100)
y, e, w = f.run(d, x)

# show results
plt.figure(figsize=(15,9))
plt.subplot(211);plt.title("Adaptation");plt.xlabel("samples - k")
plt.plot(d,"b", label="d - target")
plt.plot(y,"g", label="y - output");plt.legend()
plt.subplot(212);plt.title("Filter error");plt.xlabel("samples - k")
plt.plot(10*np.log10(e**2),"r", label="e - error [dB]");plt.legend()
plt.tight_layout()
plt.show()

Code Explanation

class padasip.filters.ocnlms.FilterOCNLMS(n, mu=0.1, eps=1.0, mem=100, **kwargs)[source]

Bases: padasip.filters.base_filter.AdaptiveFilter

Adaptive OCNLMS filter.

clear_memory()[source]

Clear of data from memory and reset memory index.

learning_rule(e, x)[source]

Override the parent class.

predict(x)[source]

This function calculates OCNLMS specific output. The parent class predict function cannot be used.

Args:

  • x : input vector (1 dimension array) in length of filter.

Returns:

  • y : output value (float) calculated from input array.

read_memory()[source]

This function read mean value of target`d` and input vector x from history

update_memory_d(d_k)[source]

This function update memory of the filter with new target value d.

update_memory_x(x_k)[source]

This function update memory of the filter with new input vector x.