sdr.p_fa(threshold: ArrayLike, sigma2: ArrayLike = 1, detector: 'coherent' | 'linear' | 'square-law' = 'square-law', complex: bool = True, n_c: int = 1, n_nc: int | None = None) NDArray[float64]

Computes the theoretical probability of false alarm \(P_{fa}\).

Parameters:
threshold: ArrayLike

The detection threshold \(\gamma\) in linear units.

sigma2: ArrayLike = 1

The noise variance \(\sigma^2\) in linear units.

detector: 'coherent' | 'linear' | 'square-law' = 'square-law'

The detector type.

  • "coherent": A coherent detector,

    \[T(x) = \mathrm{Re}\left\{\sum_{i=0}^{N_c-1} x[n-i]\right\} .\]

  • "linear": A linear detector,

    \[T(x) = \sum_{j=0}^{N_{nc}-1}\left|\sum_{i=0}^{N_c-1} x[n-i-jN_c]\right| .\]

  • "square-law": A square-law detector,

    \[T(x) = \sum_{j=0}^{N_{nc}-1}\left|\sum_{i=0}^{N_c-1} x[n-i-jN_c]\right|^2 .\]

complex: bool = True

Indicates whether the input signal is real or complex. This affects how the SNR is converted to noise variance.

n_c: int = 1

The number of samples to coherently integrate \(N_c\).

n_nc: int | None = None

The number of samples to non-coherently integrate \(N_{nc}\). Non-coherent integration is only allowable for linear and square-law detectors.

Returns:

The probability of false alarm \(P_{fa}\) in \((0, 1)\).

Notes

The probability of false alarm \(P_{fa}\) is defined as the probability that the detector output \(T(x)\) exceeds the detection threshold \(\gamma\) given that the signal is absent.

\[P_{fa} = P\left(T(x) > \gamma \mid \mathcal{H}_0\right)\]

Examples

In [1]: threshold = 1.0  # Detection threshold

In [2]: sigma2 = 1  # Noise variance

Compute the probability of false alarm for the coherent detector. Plot the PDFs and observe the theoretical \(P_{fa}\) is achieved.

In [3]: detector = "coherent"; \
   ...: h0 = sdr.h0(sigma2, detector)
   ...: 

In [4]: p_fa = sdr.p_fa(threshold, sigma2, detector); p_fa
Out[4]: 0.07864960352514258

In [5]: plt.figure(); \
   ...: sdr.plot.detector_pdfs(h0=h0, threshold=threshold); \
   ...: plt.title("Coherent Detector: Probability density functions");
   ...: 
../../_images/sdr_p_fa_1.png

Compute the probability of false alarm for the linear detector. Plot the PDFs and observe the theoretical \(P_{fa}\) is achieved.

In [6]: detector = "linear"; \
   ...: h0 = sdr.h0(sigma2, detector)
   ...: 

In [7]: p_fa = sdr.p_fa(threshold, sigma2, detector); p_fa
Out[7]: 0.3678794411714425

In [8]: plt.figure(); \
   ...: sdr.plot.detector_pdfs(h0=h0, threshold=threshold); \
   ...: plt.title("Linear Detector: Probability density functions");
   ...: 
../../_images/sdr_p_fa_2.png

Compute the probability of false alarm for the square-law detector. Plot the PDFs and observe the theoretical \(P_{fa}\) is achieved.

In [9]: detector = "square-law"; \
   ...: h0 = sdr.h0(sigma2, detector)
   ...: 

In [10]: p_fa = sdr.p_fa(threshold, sigma2, detector); p_fa
Out[10]: 0.36787944117144245

In [11]: plt.figure(); \
   ....: sdr.plot.detector_pdfs(h0=h0, threshold=threshold); \
   ....: plt.title("Square-Law Detector: Probability density functions");
   ....: 
../../_images/sdr_p_fa_3.png