Open Live Script
This example introduces constant false alarm rate (CFAR) detection and shows how to use CFARDetector and CFARDetector2D in the Phased Array System Toolbox™ to perform cell averaging CFAR detection.
One important task a radar system performs is target detection. The detection itself is fairly straightforward. It compares the signal to a threshold. Therefore, the real work on detection is coming up with an appropriate threshold. In general, the threshold is a function of both the probability of detection and the probability of false alarm.
In many phased array systems, because of the cost associated with a false detection, it is desirable to have a detection threshold that not only maximizes the probability of detection but also keeps the probability of false alarm below a preset level.
There is extensive literature on how to determine the detection threshold. Readers might be interested in the Signal Detection in White Gaussian Noise and Signal Detection Using Multiple Samples examples for some well known results. However, all these classical results are based on theoretical probabilities and are limited to white Gaussian noise with known variance (power). In real applications, the noise is often colored and its power is unknown.
CFAR technology addresses these issues. In CFAR, when the detection is needed for a given cell, often termed as the cell under test (CUT), the noise power is estimated from neighboring cells. Then the detection threshold, , is given by
where is the noise power estimate and is a scaling factor called the threshold factor.
From the equation, it is clear that the threshold adapts to the data. It can be shown that with the appropriate threshold factor, , the resulting probability of false alarm can be kept at a constant, hence the name CFAR.
Cell Averaging CFAR Detection
The cell averaging CFAR detector is probably the most widely used CFAR detector. It is also used as a baseline comparison for other CFAR techniques. In a cell averaging CFAR detector, noise samples are extracted from both leading and lagging cells (called training cells) around the CUT. The noise estimate can be computed as 
where is the number of training cells and is the sample in each training cell. If happens to be the output of a square law detector, then represents the estimated noise power. In general, the number of leading and lagging training cells are the same. Guard cells are placed adjacent to the CUT, both leading and lagging it. The purpose of these guard cells is to avoid signal components from leaking into the training cell, which could adversely affect the noise estimate.
The following figure shows the relation among these cells for the 1-D case.
With the above cell averaging CFAR detector, assuming the data passed into the detector is from a single pulse, i.e., no pulse integration involved, the threshold factor can be written as 
where is the desired false alarm rate.
CFAR Detection Using Automatic Threshold Factor
In the rest of this example, we show how to use Phased Array System Toolbox to perform a cell averaging CFAR detection. For simplicity and without losing any generality, we still assume that the noise is white Gaussian. This enables the comparison between the CFAR and classical detection theory.
We can instantiate a CFAR detector using the following command:
cfar = phased.CFARDetector('NumTrainingCells',20,'NumGuardCells',2);
In this detector we use 20 training cells and 2 guard cells in total. This means that there are 10 training cells and 1 guard cell on each side of the CUT. As mentioned above, if we assume that the signal is from a square law detector with no pulse integration, the threshold can be calculated based on the number of training cells and the desired probability of false alarm. Assuming the desired false alarm rate is 0.001, we can configure the CFAR detector as follows so that this calculation can be carried out.
exp_pfa = 1e-3;cfar.ThresholdFactor = 'Auto';cfar.ProbabilityFalseAlarm = exp_pfa;
The configured CFAR detector is shown below.
cfar = phased.CFARDetector with properties: Method: 'CA' NumGuardCells: 2 NumTrainingCells: 20 ThresholdFactor: 'Auto' ProbabilityFalseAlarm: 1.0000e-03 OutputFormat: 'CUT result' ThresholdOutputPort: false NoisePowerOutputPort: false
We now simulate the input data. Since the focus is to show that the CFAR detector can keep the false alarm rate under a certain value, we just simulate the noise samples in those cells. Here are the settings:
The data sequence is 23 samples long, and the CUT is cell 12. This leaves 10 training cells and 1 guard cell on each side of the CUT.
The false alarm rate is calculated using 100 thousand Monte Carlo trials.
rs = RandStream('mt19937ar','Seed',2010);npower = db2pow(-10); % Assume 10dB SNR ratioNtrials = 1e5;Ncells = 23;CUTIdx = 12;% Noise samples after a square law detectorrsamp = randn(rs,Ncells,Ntrials)+1i*randn(rs,Ncells,Ntrials); x = abs(sqrt(npower/2)*rsamp).^2;
To perform the detection, pass the data through the detector. In this example, there is only one CUT, so the output is a logical vector containing the detection result for all the trials. If the result is true, it means that a target is present in the corresponding trial. In our example, all detections are false alarms because we are only passing in noise. The resulting false alarm rate can then be calculated based on the number of false alarms and the number of trials.
x_detected = cfar(x,CUTIdx);act_pfa = sum(x_detected)/Ntrials
act_pfa = 9.4000e-04
The result shows that the resulting probability of false alarm is below 0.001, just as we specified.
CFAR Detection Using Custom Threshold Factor
As explained in the earlier part of this example, there are only a few cases in which the CFAR detector can automatically compute the appropriate threshold factor. For example, using the previous scenario, if we employ a 10-pulses noncoherent integration before the data goes into the detector, the automatic threshold can no longer provide the desired false alarm rate.
npower = db2pow(-10); % Assume 10dB SNR ratioxn = 0;for m = 1:10 rsamp = randn(rs,Ncells,Ntrials)+1i*randn(rs,Ncells,Ntrials); xn = xn + abs(sqrt(npower/2)*rsamp).^2; % noncoherent integrationendx_detected = cfar(xn,CUTIdx);act_pfa = sum(x_detected)/Ntrials
act_pfa = 0
One may be puzzled why we think a resulting false alarm rate of 0 is worse than a false alarm rate of 0.001. After all, isn't a false alarm rate of 0 a great thing? The answer to this question lies in the fact that when the probability of false alarm is decreased, so is the probability of detection. In this case, because the true false alarm rate is far below the allowed value, the detection threshold is set too high. The same probability of detection can be achieved with our desired probability of false alarm at lower cost; for example, with lower transmitter power.
In most cases, the threshold factor needs to be estimated based on the specific environment and system configuration. We can configure the CFAR detector to use a custom threshold factor, as shown below.
release(cfar);cfar.ThresholdFactor = 'Custom';
Continuing with the pulse integration example and using empirical data, we found that we can use a custom threshold factor of 2.35 to achieve the desired false alarm rate. Using this threshold, we see that the resulting false alarm rate matches the expected value.
cfar.CustomThresholdFactor = 2.35;x_detected = cfar(xn,CUTIdx);act_pfa = sum(x_detected)/Ntrials
act_pfa = 9.6000e-04
CFAR Detection Threshold
A CFAR detection occurs when the input signal level in a cell exceeds the threshold level. The threshold level for each cell depends on the threshold factor and the noise power in that derived from training cells. To maintain a constant false alarm rate, the detection threshold will increase or decrease in proportion to the noise power in the training cells. Configure the CFAR detector to output the threshold used for each detection using the
ThresholdOutputPort property. Use an automatic threshold factor and 200 training cells.
release(cfar);cfar.ThresholdOutputPort = true;cfar.ThresholdFactor = 'Auto';cfar.NumTrainingCells = 200;
Next, create a square-law input signal with increasing noise power.
rs = RandStream('mt19937ar','Seed',2010);Npoints = 1e4;rsamp = randn(rs,Npoints,1)+1i*randn(rs,Npoints,1);ramp = linspace(1,10,Npoints)';xRamp = abs(sqrt(npower*ramp./2).*rsamp).^2;
Compute detections and thresholds for all cells in the signal.
[x_detected,th] = cfar(xRamp,1:length(xRamp));
Next, compare the CFAR threshold to the input signal.
plot(1:length(xRamp),xRamp,1:length(xRamp),th,... find(x_detected),xRamp(x_detected),'o')legend('Signal','Threshold','Detections','Location','Northwest')xlabel('Time Index')ylabel('Level')
Here, the threshold increases with the noise power of the signal to maintain the constant false alarm rate. Detections occur where the signal level exceeds the threshold.
Comparison Between CFAR and Classical Neyman-Pearson Detector
In this section, we compare the performance of a CFAR detector with the classical detection theory using the Neyman-Pearson principle. Returning to the first example and assuming the true noise power is known, the theoretical threshold can be calculated as
T_ideal = npower*db2pow(npwgnthresh(exp_pfa));
The false alarm rate of this classical Neyman-Pearson detector can be calculated using this theoretical threshold.
act_Pfa_np = sum(x(CUTIdx,:)>T_ideal)/Ntrials
act_Pfa_np = 9.5000e-04
Because we know the noise power, classical detection theory also produces the desired false alarm rate. The false alarm rate achieved by the CFAR detector is similar.
release(cfar);cfar.ThresholdOutputPort = false;cfar.NumTrainingCells = 20;x_detected = cfar(x,CUTIdx);act_pfa = sum(x_detected)/Ntrials
act_pfa = 9.4000e-04
Next, assume that both detectors are deployed to the field and that the noise power is 1 dB more than expected. In this case, if we use the theoretical threshold, the resulting probability of false alarm is four times more than what we desire.
npower = db2pow(-9); % Assume 9dB SNR ratiorsamp = randn(rs,Ncells,Ntrials)+1i*randn(rs,Ncells,Ntrials);x = abs(sqrt(npower/2)*rsamp).^2; act_Pfa_np = sum(x(CUTIdx,:)>T_ideal)/Ntrials
act_Pfa_np = 0.0041
On the contrary, the CFAR detector's performance is not affected.
x_detected = cfar(x,CUTIdx);act_pfa = sum(x_detected)/Ntrials
act_pfa = 0.0011
Hence, the CFAR detector is robust to noise power uncertainty and better suited to field applications.
Finally, use a CFAR detection in the presence of colored noise. We first apply the classical detection threshold to the data.
npower = db2pow(-10);fcoeff = maxflat(10,'sym',0.2);x = abs(sqrt(npower/2)*filter(fcoeff,1,rsamp)).^2; % colored noiseact_Pfa_np = sum(x(CUTIdx,:)>T_ideal)/Ntrials
act_Pfa_np = 0
Note that the resulting false alarm rate cannot meet the requirement. However, using the CFAR detector with a custom threshold factor, we can obtain the desired false alarm rate.
release(cfar);cfar.ThresholdFactor = 'Custom';cfar.CustomThresholdFactor = 12.85;x_detected = cfar(x,CUTIdx);act_pfa = sum(x_detected)/Ntrials
act_pfa = 0.0010
CFAR Detection for Range-Doppler Images
In the previous sections, the noise estimate was computed from training cells leading and lagging the CUT in a single dimension. We can also perform CFAR detection on images. Cells correspond to pixels in the images, and guard cells and training cells are placed in bands around the CUT. The detection threshold is computed from cells in the rectangular training band around the CUT.
In the figure above, the guard band size is [2 2] and the training band size is [4 3]. The size indices refer to the number of cells on each side of the CUT in the row and columns dimensions, respectively. The guard band size can also be defined as 2, since the size is the same along row and column dimensions.
Next, create a two-dimensional CFAR detector. Use a probability of false alarm of 1e-5 and specify a guard band size of 5 cells and a training band size of 10 cells.
cfar2D = phased.CFARDetector2D('GuardBandSize',5,'TrainingBandSize',10,... 'ProbabilityFalseAlarm',1e-5);
Next, load and plot a range-doppler image. The image includes returns from two stationary targets and one target moving away from the radar.
[resp,rngGrid,dopGrid] = helperRangeDoppler;
Use CFAR to search the range-Doppler space for objects, and plot a map of the detections. Search from -10 to 10 kHz and from 1000 to 4000 m. First, define the cells under test for this region.
[~,rangeIndx] = min(abs(rngGrid-[1000 4000]));[~,dopplerIndx] = min(abs(dopGrid-[-1e4 1e4]));[columnInds,rowInds] = meshgrid(dopplerIndx(1):dopplerIndx(2),... rangeIndx(1):rangeIndx(2));CUTIdx = [rowInds(:) columnInds(:)]';
Compute a detection result for each cell under test. Each pixel in the search region is a cell in this example. Plot a map of the detection results for the range-Doppler image.
detections = cfar2D(resp,CUTIdx);helperDetectionsMap(resp,rngGrid,dopGrid,rangeIndx,dopplerIndx,detections)
The three objects are detected. A data cube of range-Doppler images over time can likewise be provided as the input signal to
cfar2D, and detections will be calculated in a single step.
In this example, we presented the basic concepts behind CFAR detectors. In particular, we explored how to use the Phased Array System Toolbox to perform cell averaging CFAR detection on signals and range-Doppler images. The comparison between the performance offered by a cell averaging CFAR detector and a detector equipped with the theoretically calculated threshold shows clearly that the CFAR detector is more suitable for real field applications.
 Mark Richards, Fundamentals of Radar Signal Processing, McGraw Hill, 2005
T_ideal = npower*db2pow(npwgnthresh(exp_pfa)); The false alarm rate of this classical Neyman-Pearson detector can be calculated using this theoretical threshold. Because we know the noise power, classical detection theory also produces the desired false alarm rate.How is CFAR calculated? ›
The CFAR ratio is calculated using the equation, X = - log 10 ( PFA )/ NRC .How do you calculate false alarm rate? ›
The FAR would be: number of false alarms / the total number of warnings or alarms: 8/20 = 0.40. In weather reporting, the false alarm ratio for tornado warnings is the number of false tornado warnings per total number of tornado warnings.What is a CFAR detector? ›
Constant false alarm rate (CFAR) detection refers to a common form of adaptive algorithm used in radar systems to detect target returns against a background of noise, clutter and interference.What is an acceptable false alarm rate? ›
A popular allowable rate for false discoveries, typically called q, is 10%.What is false alarm examples? ›
Meaning of false alarm in English. an occasion when people wrongly believe that something dangerous or unpleasant is happening or will happen: Three fire engines rushed to the school only to discover it was a false alarm. She thought she was pregnant, but it turned out to be a false alarm (= she was not).What is the objective of CFAR? ›
As a public interest research and advocacy group, CFAR helps create spaces in the community, in the key institutions and in the media for a dialogue on issues related to social development.What is the constant detection rate? ›
On the other hand, if it is required to guarantee a non-interference probability to the primary users, the probability of detection should be set to a high level (e.g., 95%) and the probability of false alarm should be minimized as much as possible. This is called the constant detection rate (CDR) principle [13,19].What is CFAR coverage? ›
That's where “cancel for any reason” coverage (CFAR) comes in. It's an upgrade that allows you to cancel for any reason and generally provides 75% reimbursement of your nonrefundable trip costs.What is the difference between false alarm rate and false alarm ratio? ›
The PAG is the fraction of forecasts which were correct, and is not widely used. Thus, F is the fraction of non-events which were forecast as false alarms. The false alarm rate is sometimes called the probability of false detection (POFD). In that sense, it is akin to false positives on a medical test, or on an X-ray.
For example, when you are walking and suddenly find a “snake” in the grass by the side of the road, you will instantly have a strong sense of fear, but as soon as you find out that it is a toy snake, the fear will rapidly subside; this is a False Alarm.How many alarms are false? ›
In the United States, between 94% and 98% of all burglar alarm activations are falsely triggered.What are the different types of CFAR detection? ›
- Cell Averaging CFAR.
- CAOS-CFAR oder OS-CFAR.
A typical radar system will operate with a detection probability of 0.9 and a probability of false alarm of 10-6. The required signal to noise ratio can be read directly off the graph as 13.2dB.What is the difference between CA CFAR and OS-CFAR? ›
Two-dimensional constant-false alarm rate (2D-CFAR) will be developed to minimize noise detected rather than using one dimensional CFAR. ... ... CA-CFAR has good performance on homogenous environment and the other hand OS-CFAR has good performance on non homogenous environment and multiple targets - .How do I reduce false alarms? ›
Here are five easy ways you can prevent false alarms in your home. Turn sensors away from air/heat vents, fans, and windows so they don't pick up any breezes or drafts that could prompt a false alarm. Additionally, make sure you keep all moving objects away from the sensors when your alarm is set.How can false alarms be avoided? ›
To avoid these false alarms, adjust door and window latch mechanisms to minimize movement while closed. Additionally, rattle and shake all alarm sensor equipped doors and windows to ensure that the sensors are not triggered due to the allowed movement.What is the main reason for false alarm? ›
Excessive dust, spider webs, and loose sensors and detectors can all be the source of false alarms.What's another word for false alarm? ›
On this page you'll find 5 synonyms, antonyms, and words related to false alarm, such as: cry of wolf, dud, and nonstarter.What kind of error will result in a false alarm? ›
A false alarm is an alarm call for service in which police determine the alarm was caused by anything other than a criminal offence, medical or fire emergency. The most common causes of false alarms include user error, faulty equipment and household pets.
CFaR is a more suitable approach to modeling risk because it measures the potential cash flow shortfalls over a much longer time horizon than VaR, and it incorporates longer term changes in market prices.What are the main objectives of a risk management plan and why is it so important to implement one? ›
Essentially, the goal of risk management is to identify potential problems before they occur and have a plan for addressing them. Risk management looks at internal and external risks that could negatively impact an organization.What are the benefits of risk reduction plan? ›
Helps you avoid losses: By preparing for risks, you can avoid or minimize the losses that might occur if something goes wrong. Protects your reputation: If you are able to successfully mitigate risk, it can protect your company's reputation.What are the 4 possible outcomes of signal detection theory? ›
Internal response probability density functions.
There are four possible outcomes: hit (signal present and subject says “yes”), miss (signal present and subject says “no”), false alarm (signal absent and subject says “yes”), and correct rejection (signal absent and subject says “no”).
Signal Detection Theory Examples
Detecting an emergency vehicle's siren in the background noise of a busy city street. In this case, the signal is the siren, and the noise is the other traffic sounds.
There is a consensus on the definition of the detection rate,also called True Positive Rate (TPR): TPR=TPTP+FN.What is CFAR reimbursement? ›
CFAR is supplemental coverage that offers partial reimbursement when you cancel a nonrefundable trip for any reason that isn't covered by your travel insurance policy. You cannot buy CFAR on its own; it's an optional upgrade added when you buy primary travel insurance.What are the main 5 categories of travel insurance coverage? ›
Here's the very short answer: Cancellations, medical expenses, evacuations, loss or delays, and 24/7 assistance. These are the 5 basic types of coverage provided with vacation insurance. This is the #1 concern with most travelers.What is the difference between trip interruption and trip delay insurance? ›
A trip delay occurs when your travel is delayed for a specific amount of time, usually several hours. On the other hand, a trip interruption occurs when your travel plans are disrupted or cut short due to unforeseen circumstances such as illness, injury, or death in the family.Is false alarm false positive? ›
A false positive is when a scientist determines something is true when it is actually false (also called a type I error). A false positive is a “false alarm.” A false negative is saying something is false when it is actually true (also called a type II error).
A false alarm is… when there isn't actually a real fire but the alarm goes off. There can be lots of reasons, other than a real fire, why the alarm goes off: Cooking fumes (e.g. burnt toast)How many alarms is too many alarms? ›
The answer is just one, because setting multiple alarms to wake up may actually be harmful to your health. Despite almost one-third of adults saying they hit the snooze button over and over again, as they feel deprived of sleep, this makes you feel worse.How many alarms are normal? ›
The average American sets four different alarms to wake up on a normal day. However, about one in 10 of those surveyed don't set an alarm at all. Thirty-two percent of non-alarm clockers eat breakfast every day of the week, compared to only seven percent of those who set about nine to 10 alarms.What is constant false alarm rate in Python? ›
Constant false alarm rate (CFAR) methods are designed to maintain a constant false alarm during threshold calculation for target detections using a power profile 1. In fact, a profile can be a profile obtained by observing a particular sensor output.What is radar threshold? ›
Radar threshold is a parameter that affects radar performance directly by causing a trade off between detection and false alarm probability. While designing radar systems, it must be set accurately in order to have reliable decisions about target detection.What are the different types of signal detection? ›
The four possibilities in signal detection theory are hit, miss, false alarm, and correct rejections.What is an example of false alarm in signal detection theory? ›
Either the doctor sees a tumor (they respond "yes'') or does not (they respond "no''). There are four possible outcomes: hit (tumor present and doctor says "yes''), miss (tumor present and doctor says "no''), false alarm (tumor absent and doctor says "yes"), and correct rejection (tumor absent and doctor says "no").Which radar detector is undetectable? ›
The Genevo Pro M is a remote mount electronically undetectable radar/laser detector which can d...How to calculate FDR in MATLAB? ›
Use mafdr to calculate the positive FDR values. fdr = mafdr(pvalues); Calculate the q-values, a priori probability (that the null hypothesis is true), and R-squared value.How to calculate error rate in MATLAB? ›
- Copy Code Copy Command. Create two binary vectors and determine the error statistics. ...
- errorRate = comm. ErrorRate; ...
- tx = [1 0 1 0 1 0 1 0 1 0]'; Introduce errors to the first and last bits.
- rx = tx; rx(1) = ~rx(1); rx(end) = ~rx(end); ...
- y = errorRate(tx,rx); ...
- ans = 0.2000. ...
- ans = 2. ...
- ans = 10.
First, the user needs to create an array called "data" containing these observations in MATLAB. Next, the user can calculate the standard error of the mean with the command "stderror = std( data ) / sqrt( length )".How do you calculate Dprime? ›
The formula for d prime is d' = z(H) - z(F) , where z(H) and z(F) are the z transforms of hit rate and false alarm, respectively.How to calculate R value in MATLAB? ›
R = corrcoef( A ) returns the matrix of correlation coefficients for A , where the columns of A represent random variables and the rows represent observations. R = corrcoef( A , B ) returns coefficients between two random variables A and B .How do you calculate FDR from P values? ›
The total number of rejections of the null include both the number of false positives (FP) and true positives (TP). Simply put, FDR = FP / (FP + TP).Is FDR the same as adjusted P value? ›
The FDR is the ratio of the number of false positive results to the number of total positive test results: a p-value of 0.05 implies that 5% of all tests will result in false positives. An FDR-adjusted p-value (also called q-value) of 0.05 indicates that 5% of significant tests will result in false positives.What are the 3 types of errors in MATLAB? ›
|error||Throw error and display message|
|warning||Display warning message|
|lastwarn||Last warning message|
|assert||Throw error if condition false|
|onCleanup||Cleanup tasks upon function completion|
Conversely, the error rate can be calculated as the total number of incorrect predictions made on the test set divided by all predictions made on the test set. The accuracy and error rate are complements of each other, meaning that we can always calculate one from the other. For example: Accuracy = 1 – Error Rate.How do you track error rate? ›
Error Rate Formula
To calculate an error rate, divide the total number of words by the total number of errors.
If you encounter run-time errors in your MATLAB® functions, the run-time stack appears in the MATLAB command window. Use the error message and stack information to learn more about the source of the error, and then either fix the issue or add error-handling code.What is STD () in MATLAB? ›
Description. S = std( A ) returns the standard deviation of the elements of A along the first array dimension whose size is greater than 1. By default, the standard deviation is normalized by N-1 , where N is the number of observations. If A is a vector of observations, then S is a scalar.
Standard error is calculated by dividing the standard deviation of the sample by the square root of the sample size.What is the meaning of Dprime? ›
(symbol: d′) a measure of an individual's ability to detect signals; more specifically, a measure of sensitivity or discriminability derived from signal detection theory that is unaffected by response biases.