User-Defined Filter

 

Updated: June 21, 2016

Creates a custom finite or infinite impulse response filter

You can use the User-Defined Filter module to define a custom filter by using a finite impulse response (FIR) filter or an infinite impulse response (IIR) filter with coefficients that you specify.

This module is particularly useful for applying a set of previously derived filter coefficients to your data.

After you have defined a filter that meets your needs, you can apply the filter to data by connecting a dataset and the filter to the Apply Filter module.

To define a custom filter:

  1. Define the general type of filter: FIR filter, or IIR filter.

  2. Provide the coefficients.

    The requirements for the coefficients differ depending on whether you choose a FIR filter or an IIR filter.

    • For a FIR filter, you specify a vector of feed-forward coefficients. The length of the vector determines the filter's order.

      A FIR filter is effectively a moving average, so the configuration values apply a moving average to filter a data sequence.

    • For an IIR filter, you apply custom feed-forward and feed-backward coefficients. The following examples demonstrate some configuration values.

See the Examples section for links to experiments that use the filter modules.

For an exponentially weighted moving average, all coefficients are less than one and the sum of all coefficients equals one. Therefore, the variance of the weighted average will always be less than the input values.

For example, for a FIR filter to approximate an exponentially weighted moving average (WMA), you would supply a comma-separated list of coefficients for the value for the feed-forward parameter:

0.01818182, 0.03636364, 0.05454545, 0.07272727, 0.09090909, 0.10909091, 0.12727273, 0.14545455, 0.16363636, 0.18181818

This FIR filter approximates a triangularly weighted moving average (WMA).

You define the coefficients by supplying a comma-separated series of values for the feed-forward parameters, such as these:

0.0625, 0.0625 0.2500, 0.3750, 0.2500, 0.0625

The values used in this custom FIR filter represent a vector of feed-forward coefficients obtained by using the Deslauriers-Dubuc method of finite sequencing. For more information, see Dubuc-Deslauriers Subdivision for Finite Sequences and Interpolation Wavelets on an Interval-.

A good example of an application for a user-defined IIR filter is to define a notch filter, also called a bandstop filter.

The desired notch filter attenuates a -3dB rejection band, fb, centered at a notch frequency, fn, with a sampling frequency, fs:

The digital notch filter can be represented by:

custom notch filter example 1

Where:

custom notch filter

   

From this form, we can get the feed-forward coefficient:

feed forward coefficient for custom notch filter

   

And the feed-backward coefficients as:

feed back coefficient for custom notch filter

Following is an example of a notch filter with a notch frequency of f n =1250 Hz and a -3 dB rejection band of fb =100 Hz, with sampling frequency of fs=10 kHz.

formula for notch filter example 2-1

If we use:

formulas 2 for notch filter example 2

We get:

a 2 = 0.93906244

a 1 = 1.3711242

From this, the feed-forward (b) and feed-backward (a) coefficients are:

b= 1.9390624, -2.7422484, 1.9390624

a= 1, -1.3711242, 0.9390624

For more examples of how filters are used in machine learning, see these experiments in the Model Gallery:

  • The Filters experiment demonstrates all filter types. The example uses an engineered waveform dataset to more easily illustrate the effects of the different filters.

Name

Range

Type

Default

Description

Type of filter

any

ImpulseResponse

Specify the type of filter to customize

Forward

any

String

"1.0"

Type a series of feed-forward coefficients

Backward

any

String

"1.0"

Type a series of feed-backward filter coefficients

Name

Type

Description

Filter

IFilter interface

Filter implementation

For a list of all exceptions, see Machine Learning REST API Error Codes.

Exception

Description

ParameterParsing

An exception occurs if one or more parameters could not be parsed or converted from the specified type into the type that is required by the target method.

Show: