check_filter | R Documentation |
Check 'Arma' filter
check_filter(b, a, w = NULL, r_expected = NULL, fs = NULL)
b |
moving average ( |
a |
auto-regressive ( |
w |
normalized frequency, ranging from 0 to 1, where 1 is 'Nyquist' |
r_expected |
attenuation in decibel of each |
fs |
sample rate, used to infer the frequencies and formatting print message, not used in calculation; leave it blank by default |
A list of power estimation and the reciprocal condition number
of the AR
coefficients.
# create a butterworth filter with -3dB (half-power) at [1, 5] Hz
# and -60dB stop-band attenuation at [0.5, 6] Hz
sample_rate <- 20
nyquist <- sample_rate / 2
specs <- buttord(
Wp = c(1, 5) / nyquist,
Ws = c(0.5, 6) / nyquist,
Rp = 3,
Rs = 60
)
filter <- butter(specs)
# filter quality is poor because the AR-coefficients
# creates singular matrix with unstable inverse,
# this will cause `filtfilt` to fail
check_filter(
b = filter$b, a = filter$a,
# frequencies (normalized) where power is evaluated
w = c(1, 5, 0.5, 6) / nyquist,
# expected power
r_expected = c(3, 3, 60, 60)
)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.