Investment Studio > Expressions > Functions > DSP > MAKE_RESONATOR
float array[1][4] make_resonator(float normalized_frequency, float zero_gain, float peak_gain)
Returns the filter coefficients for a resonator with the specified normalized_frequency (range ]0, 0.5[, where 1 is the sampling rate), zero_gain Î [0, ¥[ and peak_again Î [zero_gain, ¥[.
A resonator is an amplifier with a frequency response containing an approximately bell-shaped peak.
The normalized_frequency is the peak's central frequency, expressed as a fraction of the sampling rate (hence the "normalized" in normalized_frequency). 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 normalized frequency limit of 0.5 then means that cycles shorter than 1 / 0.5 = 2 days can not be amplified. 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), so normalized frequencies higher than 0.5 can not be resolved, let alone amplified.
The zero_gain is the amplification factor at the left end of the spectrum (zero frequency).
The peak_gain is the amplification factor at the top of the resonant peak.
Examples
To explore the resonator's behaviour, we can exploit the fact that the frequency response of any linear, time-invariant filter is just the Fourier transform of the filter's impulse response (the filter's output when the input sequence is a unit impulse, i.e. a single 1 surrounded by zeros, effectively all the way both to positive and to negative infinity).
This means that we can visualize the difference in frequency response between different resonators by passing a unit impulse through each one and computing the Fourier transforms of their output.
With the symbol definitions
_impulse = index(m1(1024), 0, 1)
_01_10 = fftp(resonate(make_resonator(0.1, 1, 10), 1, array(_impulse)))
_02_10 = fftp(resonate(make_resonator(0.2, 1, 10), 1, array(_impulse)))
_03_10 = fftp(resonate(make_resonator(0.3, 1, 10), 1, array(_impulse)))
_04_10 = fftp(resonate(make_resonator(0.4, 1, 10), 1, array(_impulse)))
the graph sources
=1024 * index(array(_01_10), x + 1, 1)
=1024 * index(array(_02_10), x + 1, 1)
=1024 * index(array(_03_10), x + 1, 1)
=1024 * index(array(_04_10), x + 1, 1)
(where the "+ 1" is to skip the zeroth, constant "harmonic") yield the following amplitude response curves (red for normalized_frequency = 0.1, green for 0.2, blue for 0.3, black for 0.4):

With the same symbol definitions as above, the graph sources
=index(array(_01_10), x + 1, 2)
=index(array(_02_10), x + 1, 2)
=index(array(_03_10), x + 1, 2)
=index(array(_04_10), x + 1, 2)
give us the following phase response curves:

See also make_ema, make_hipass, make_lopass, make_notch, resonate.