Investment Studio > Expressions > Functions > DSP > MAKE_HIPASS

float array[*][4] make_hipass(integer poles, float normalized_cutoff)

Returns the parameters needed to turn the hipass function into a Butterworth high pass filter with the specified number of poles (> 0) and normalized_cutoff frequency (range ]0, 0.5[, where 1 is the sampling rate).

An ideal high pass filter blocks all frequencies below the specified cutoff frequency. A real-life high pass filter has a finite transition band where the amplitude response ramps up, and will introduce both amplitude and phase variations in the passband (the frequency range above the cutoff frequency). A Butterworth filter is defined by the property that the amplitude response is maximally flat in the passband, i.e. unwanted amplitude variations are minimized.

The make_hipass function returns an array containing (poles div 2) + (poles mod 2) rows. Each row contains the coefficients {b0, b1, a1, a2} of a second order IIR (Infinite Impulse Response) filter implementing the difference equation

y[n] = b0 * x[n] + b1 * x[n - 1] + a1 * y[n - 1] + a2 * y[n - 2]

where x[n] is the input sequence and y[n] is the filter's output. The Butterworth filter is constructed by running all these second order filters in parallell and adding up their output. In this sense, each row in the array returned by make_hipass is a filter element.

Increasing the number of poles reduces the width of the filter's transition band (i.e. it makes the filter better at separating the frequencies around the cutoff frequency) but it also leads to larger phase distortion. See the hipass examples for an illustration of this tradeoff. The improvement drops off for each additional pole, and the finite precision of computer arithmetics sets an absolute limit at about 50 poles. Beyond that, the filter's output may become unpredictable. In most cases, there is little point to going beyond 30 poles.

The filter's cutoff frequency is expressed as a fraction of the sampling rate (hence the "normalized" in normalized_cutoff). The sampling rate is the inverse of the sampling period. For a data series containing one value per day, the period is one day and the sampling rate is one per day; the upper cutoff frequency limit of 0.5 then means that cycles shorter than 1 / 0.5 = 2 days can not be resolved. This is because half the sampling rate (the Nyqvist frequency) is the highest frequency component that can be reconstructed from a sequence of evenly sampled values (Nyqvist's theorem).

Examples

See hipass.

See also make_ema, make_lopass, make_notch, make_resonator.