📄 roc.m
字号:
function [P_d,FAD] = roc(lr_tgt,lr_clutter,num_sq_km,P_d_lim,...
FAD_lim, lintype)
% This routine provides a convenient way to produce Pd/FAD information
% from likelihood ratio information. To be more specific, consider the
% hypothesis test
%
% target present >=
% Declare if lr T
% target absent <
%
% where lr is the test statistic (e.g., a likelihood ratio or log-likelihood
% ratio). As the threshold T is varied from -infinity to +infinity,
% corresponding probability of detection and false-alarm density (i.e.,
% the average number of false alarms per square kilometer) will sweep
% over the whole ROC curve.
% This routine estimates this ROC curve from available samples of the
% test statistic lr, drawn from the conditional distributions of targets
% and clutter. Alternatively, if no output arguments are specified, then
% the routine simply plots the estimated ROC curve in the current
% figure window; in keeping with standard conventions for SAR ATR
% ROC plots, a logarithmic scale is used for the x-axis and a linear
% scale for the y-axis.
%
% [P_d, FAD] = roc(lr_tgt, lr_clutter, num_sq_km, P_d_lim, ...
% FAD_lim, lintype)
%
% INPUTS
% lr_tgt Samples of test statistic, drawn from tgt distribution
% lr_clutter Samples of test statistic, drawn from clutter
% distribution
% num_sq_km Number of square kilometers of terrain used to generate
% samples
% P_d_lim (OPTIONAL) 2-D vector, containing lower and upper
% limits of y-axis, for plot of ROC curve
% FAD_lim (OPTIONAL) 2-D vector, containing lower and upper
% limits of x-axis, for plot of ROC curve
% lintype (OPTIONAL) Type of line to use in plot, where the
% available types are the standard ones for MATLAB
% plots
% OUTPUTS
% P_d (OPTIONAL) Estimate of P_d, from available samples
% FAD (OPTIONAL) Estimate of FAD, from available samples
% courtesy William Irving, ALPHATECH, 9/96
num_tgt = length(lr_tgt);
num_clutter = length(lr_clutter);
sorted_tgt = sort(lr_tgt);
P_d = zeros(num_tgt, 1);
FAD = zeros(num_tgt, 1);
for i = 1:num_tgt
P_d(i) = (num_tgt-i+1) / num_tgt;
FAD(i) = sum(lr_clutter >= sorted_tgt(i)) / num_sq_km;
end
if (nargin >= 4)
loc = find(P_d >= P_d_lim(1) & P_d <= P_d_lim(2));
P_d = P_d(loc);
FAD = FAD(loc);
end
if (nargin >= 5)
loc = find(FAD >= FAD_lim(1) & FAD <= FAD_lim(2));
P_d = P_d(loc);
FAD = FAD(loc);
end
if (nargout == 0)
if (nargin < 6)
semilogx(FAD, P_d)
else
semilogx(FAD, P_d, lintype)
end
xlabel('False Alarms per Square Kilometer');
ylabel('Probability of Detection');
grid on;
FAD = [];
P_d = [];
end
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -