Skip to contents

Computes the quality of reconstruction factor of an estimate against a reference component, in decibels.

Usage

measureQRF(estimate, reference)

Arguments

estimate

Finite numeric vector without dim.

reference

Finite numeric vector without dim, of the length of estimate, with a nonzero norm.

Details

$$\mathrm{QRF}(\hat s, s) = 20 \log_{10} \frac{\|s\|_2}{\|s - \hat s\|_2},$$ Inf when the estimate equals the reference.

Value

A number in dB.

Conditions

A reference of zero norm is outside the domain of the factor and stops the function with an error.

Examples

Time <- seq_len(1000) / 1000
Signal <- cos(2 * pi * 2 * Time) + 0.25 * cos(2 * pi * 24 * Time) +
    0.0625 * cos(2 * pi * 288 * Time)
# The signal without its third tone, against the signal.
measureQRF(estimate = Signal - 0.0625 * cos(2 * pi * 288 * Time),
           reference = Signal)
#> [1] 24.36163
measureQRF(estimate = Signal, reference = Signal)
#> [1] Inf