Main Content

phased.LRTDetector

Likelihood ratio test detector

Since R2023b

Description

The likelihood ratio test (LRT) detector performs binary signal detection in the presence of noise. The binary detector chooses between the null hypothesis H0 and the alternative hypothesis H1 based on data measurements. The null hypothesis denotes the absence of any signal while the alternative hypothesis denotes the presence of some signal.

Creation

Description

example

detector = phased.LRTDetector creates a likelihood ratio test detector System object™ with default properties.

detector = phased.LRTDetector(Name = Value) creates a likelihood ratio test detector System object with the specified property Name set to the specified Value. You can specify additional name-value pair arguments in any order as (Name1 = Value1, … ,NameN = ValueN).

Properties

expand all

Unless otherwise indicated, properties are nontunable, which means you cannot change their values after calling the object. Objects lock when you call them, and the release function unlocks them.

If a property is tunable, you can change its value at any time.

For more information on changing property values, see System Design in MATLAB Using System Objects.

Data complexity, specified as 'Complex' or 'Real'. Complexity defines the format used to report output data. When DataComplexity is 'Complex', data is complex-valued. When DataComplexity is 'Real', data is real-valued.

Example: 'Real'

Data Types: char | string

Probability of false alarm, specified as a positive scalar between 0 and 1, inclusive.

Example: 1e-6

Data Types: single | double

Output detection statistics and detection threshold, specified as false or true. Set this property to true to output the detection statistics in the stat argument and the detection threshold in the th argument. Set this property to false to suppress the output of detection statistics and threshold.

Data Types: logical

Format of output data, specified as 'Detection result' or 'Detection index'. Output data is returned in the Y argument.

Example: 'Detection index'

Data Types: char | string

Usage

Description

example

Y = detector(X,Xknown,ncov) performs LRT detection on the real or complex input data X, returning detections results Y. Xknown is the known noise-free signal and ncov is the noise covariance.

example

[Y,stat,th] = detector(X,Xknown,ncov) also returns the detection statistics stat and the detection threshold th.

Input Arguments

expand all

Input data, specified as a real-valued or complex-valued N-by-1 vector, or an N-by-M real-valued or complex-valued matrix. N is the signal length and M is the number of data channels. Each data channel has N samples to yield an N-by-M matrix. Each row represents the components of a length-M data vector. When M = 1, X represents a single channel of data. When M > 1, X can represent N samples from M data channels. The detector processes input data along the columns of X. The size of each row M cannot change during the simulation.

The LRT detector assumes the same signal model in each column of X. Xknown contains the N-dimensional noise-free signal. ncov defines the power of additive Gaussian noise added to each column. For this signal model, the LRT detector determines whether or not to reject the null hypothesis Xknown = 0. Because there is only one known signal model, the LRT detector outputs one detection result for each column of X.

Data Types: single | double
Complex Number Support: Yes

Known noise-free signal, specified as a real-valued or complex-valued N-by-1 vector.

Data Types: single | double
Complex Number Support: Yes

Noise power or covariance, specified as a positive scalar.

Example: 2.0

Data Types: single | double

Output Arguments

expand all

Detection results, returned as a 1-by-M logical-valued vector or a 1-by-L integer-valued vector. The format of Y depends on the value of the OutputFormat property. By default, the OutputFormat property is set to 'Detection result'.

  • When the OutputFormat property is set to 'Detection result', Y is a 1-by-M vector containing logical detection results, where M is the number of columns of X. Y is true if there is a detection in the corresponding column of X. Otherwise, Y is false.

  • When the OutputFormat property is set to 'Detection index', Y is a 1-by-L integer-valued vector containing detection indices, where L is the number of detections found over all M channels.

Data Types: single | double | logical
Complex Number Support: Yes

Detection statistics, returned as a 1-by-M vector or 1-by-L vector. M is the number of columns of X . The format of stat depends on the setting of the OutputFormat property.

  • When OutputFormat is 'Detection result', stat has the same size as Y.

  • When OutputFormat is 'Detection index', stat is a 1-by-L vector containing detection statistics for each corresponding detection in Y.

Dependencies

To enable this argument, set the ThresholdOutputPort property to true.

Data Types: single | double

Detection threshold, returned as a scalar.

Dependencies

To enable this argument, set the ThresholdOutputPort property to true.

Data Types: single | double

Object Functions

To use an object function, specify the System object as the first input argument. For example, to release system resources of a System object named obj, use this syntax:

release(obj)

expand all

stepRun System object algorithm
releaseRelease resources and allow changes to System object property values and input characteristics
resetReset internal states of System object

Examples

collapse all

Perform likelihood ratio test detection on 10 signals in complex Gaussian noise. The input is a known signal vector of ones. The noise covariance is unity. Set the desired probability of false alarm to 0.1. Perform the detection on all samples of the input. Show that the probability of false alarm is close to the desired level.

rng default
lrt = phased.LRTDetector('DataComplexity','Complex', ...
    'ProbabilityFalseAlarm',0.1);
N = 10;
M = 1000;
x = 1/sqrt(2)*(randn(N,M) + 1i*randn(N,M));
xknown = 100*ones(N,1);
noisecov = 1;
dresult = lrt(x,xknown,noisecov);
Pfa = sum(dresult)/M
Pfa = 0.1060

Perform likelihood ratio test detection on 10 signals in real Gaussian noise. The input known signal is a vector of ones. Set the noise covariance to 1 and set the desired probability of false alarm to 0.1. Perform the detection on all samples of the input. Show that the probability of false alarm is close to the desired level.

rng default
lrt = phased.LRTDetector(DataComplexity = 'Real', ...
    ProbabilityFalseAlarm = 0.1,ThresholdOutputPort = true);
N = 10;
M = 1000;
x = randn(N,M);
xknown = 100*ones(N,1);
noisecov = 1;
[dresult,stat,th] = lrt(x,xknown,noisecov);

Display the proobability of false alarm, the first 10 values of stat, and the threshold th.

Pfa = sum(dresult)/M
Pfa = 0.1060
stat(1:10)
ans = 1×10

    1.9742    2.2291    1.0325   -1.3958    0.6511   -0.3462    0.4053   -0.8368    0.9581   -0.7792

th
th = 1.2816

This example shows how to empirically compute the probability of false alarm for real-valued data in white Gaussian noise.

Determine the required signal-to-noise ratio (SNR) in decibels for the NP detector (also known as the LRT detector) when the maximum tolerable false-alarm probability is 10-3.

% Probability of false alarm
pfa = 1e-3;

% SNR threshold in dB
snrThdB = npwgnthresh(pfa,1,'real');

% SNR threshold
snrThNP = sqrt(db2pow(snrThdB));

Assume the variance is 2 and generate 1 million samples of real Gaussian noise under the null hypothesis.

rng default

% Noise variance
variance = 2;

% Number of independent samples
M = 1e6;

% Data under null hypothesis
x = sqrt(variance) * randn(1,M);

Verify empirically that the detection threshold results in the desired false-alarm rate under the null hypothesis. This can be verified by determining the proportion of normalized samples that exceed the required SNR threshold.

% Empirical false-alarm rate
falseAlarmRateNP = sum(x/sqrt(variance) > snrThNP)/M
falseAlarmRateNP = 9.9500e-04

Alternatively, use phased.LRTDetector to empirically calculate the detection result and false alarm rate. The LRT detector requires inputting the noise-free signal under the alternative hypothesis. As we test the null hypothesis, the amplitude of the noise-free signal under the alternative hypothesis is irrelevant to the testing and can be set to any real value. Set the noise-free signal under the alternative hypothesis to be 10.

% Configure the LRT detector
lrt = phased.LRTDetector('DataComplexity','Real',...
    'ProbabilityFalseAlarm',pfa,'ThresholdOutputPort',true);

% Known noise-free signal under the alternative hypothesis
xnoisefree = 10;

% LRT detection
[dresult,stat,snrThLRT] = lrt(x,xnoisefree,variance);

% Empirical false-alarm rate
falseAlarmRateLRT = sum(dresult)/M
falseAlarmRateLRT = 9.9500e-04

The false alarm rates estimated using the above two methods are consistent.

% Difference between SNR thresholds calculated by npwgnthresh and LRT detector
thmse = abs(snrThNP-snrThLRT)^2
thmse = 1.9722e-31

The SNR thresholds generated from npwgnthresh and phased.LRTDetector are also consistent.

Plot the first 10,000 samples of detection statistics. The red horizontal line shows the detection threshold of the LRT detector. The yellow circle shows the detected false alarm.

% Plot detection statistics
x1 = stat(1:1e4);
plot(x1)

% Plot detection threshold
line([1 length(x1)],[snrThLRT snrThLRT],'Color','red')
hold on

% Plot detection results
dindex = find(dresult(1:1e4));
plot(dindex,stat(dindex),'o');
xlabel('Sample')
ylabel('Value')

You can see that few sample values exceed the threshold. This result is expected because of the low false-alarm probability.

This example shows how to empirically verify the probability of false alarm in a system that uses coherent detection of complex-valued signals. Coherent detection means that the system utilizes information about the phase of the complex-valued signals.

Determine the required SNR for the NP detector (the LRT detector) in a coherent detection scheme with one sample. Use a maximum tolerable false-alarm probability of 10-3.

% Probability of false alarm
pfa = 1e-3;

% SNR threshold in dB
snrThdB = npwgnthresh(pfa,1,'coherent');

% SNR threshold
snrThNP = sqrt(db2pow(snrThdB));

Test that this threshold empirically results in the correct false-alarm rate. The sufficient statistic in the complex-valued case is the real part of the received sample.

rng default

% Noise variance
variance = 5;

% Number of independent samples
M = 1e6;

% Data under null hypothesis
x = sqrt(variance/2)*(randn(1,M)+1j*randn(1,M));

% Empirical false-alarm rate
falseAlarmRateNP = sum(real(x)/sqrt(variance)>snrThNP)/M
falseAlarmRateNP = 9.9500e-04

Alternatively, use phased.LRTDetector to empirically calculate the detection result and false alarm rate. The LRT detector requires inputting the noise-free signal under the alternative hypothesis. As we test the null hypothesis, the complex amplitude of the noise-free signal under the alternative hypothesis is irrelevant to the testing and can be set to any real value. Set the noise-free signal under the alternative hypothesis to be amplitude 10 with random phase.

% Configure the LRT detector
lrt = phased.LRTDetector('DataComplexity','Complex',...
    'ProbabilityFalseAlarm',pfa,'ThresholdOutputPort',true);

% Known noise-free signal under the alternative hypothesis
xnoisefree = 10*exp(1j*2*pi*rand);

% LRT detection
[dresult,~,snrThLRT] = lrt(x,xnoisefree,variance);

% Empirical false-alarm rate
falseAlarmRateLRT = sum(dresult)/M
falseAlarmRateLRT = 9.6300e-04

The false alarm rates estimated using the above two methods are consistent.

% Difference between SNR thresholds calculated by npwgnthresh and LRT detector
thmse = abs(snrThNP-snrThLRT)^2
thmse = 0

The SNR thresholds generated from npwgnthresh and phased.LRTDetector are also consistent.

More About

expand all

References

[1] Steven M. Kay, Fundamentals of Statistical Signal Processing, Detection Theory, Prentice-Hall PTR, 1993.

[2] Mark A. Richards, Fundamentals of Radar Signal Processing, Third edition, McGraw-Hill Education, 2022.

Extended Capabilities

C/C++ Code Generation
Generate C and C++ code using MATLAB® Coder™.

Version History

Introduced in R2023b