saftig.filtering.lms_c¶
faster LMS filter implemented in c
Classes¶
LMS filter implementation in C (faster but harder to adjust) |
Module Contents¶
- class saftig.filtering.lms_c.LMSFilterC(n_filter, idx_target, n_channel, step_scale=0.1, normalized=True, coefficient_clipping=None)¶
Bases:
saftig.filtering.common.FilterBaseLMS filter implementation in C (faster but harder to adjust)
- Parameters:
n_filter (int) – Length of the FIR filter (how many samples are in the input window per output sample)
idx_target (int) – Position of the prediction
n_channel (int) – Number of witness sensor channels
normalized (bool) – if True: NLMS, else LMS
step_scale (float) – the learning rate of the LMS filter
coefficient_clipping (float | None) –
>>> import saftig as sg >>> n_filter = 128 >>> witness, target = sg.evaluation.TestDataGenerator(0.1).generate(int(1e5)) >>> filt = sg.filtering.LMSFilterC(n_filter, 0, 1) >>> filt.condition(witness, target) >>> prediction = filt.apply(witness, target) # check on the data used for conditioning >>> residual_rms = sg.evaluation.rms(target-prediction) >>> residual_rms > 0.05 and residual_rms < 0.15 # the expected RMS in this test scenario is 0.1 True
- filter_name: str = 'LMS_C'¶
- filter¶
- static supports_saving_loading()¶
Indicates whether saving and loading is supported.
- reset()¶
reset the filter coefficients to zero
- Return type:
None
- condition(witness, target)¶
Use an input dataset to condition the filter
- Parameters:
witness (collections.abc.Sequence[float] | collections.abc.Sequence[collections.abc.Sequence[float]]) – Witness sensor data
target (collections.abc.Sequence[float]) – Target sensor data
- apply(witness, target, pad=True, update_state=False)¶
Apply the filter to input data
- Parameters:
witness (collections.abc.Sequence | numpy.typing.NDArray) – Witness sensor data
target (collections.abc.Sequence | numpy.typing.NDArray) – Target sensor data (is ignored)
pad (bool) – if True, apply padding zeros so that the length matches the target signal
update_state (bool) –
- Returns:
prediction
- Return type:
numpy.typing.NDArray