www.gusucode.com > phased 案例源码 matlab代码程序 > phased/ComputeDetectionThresholdFromPfaExample.m

    %% Compute detection threshold from Pfa
% Calculate the detection threshold that achieves a probability of false alarm
% (pfa) of 0.01. Assume a single pulse with a |real| detection type. Then,
% verify that this threshold produces a pfa of approximately 0.01. Do this
% by constructing 10000 real white gaussian noise (wgn) samples and computing the
% fraction of samples exceeding the threshold. 

% Copyright 2015 The MathWorks, Inc.


%%
% Compute the threshold from pfa. The detection threshold is
% expressed as a signal-to-noise ratio in db.
pfa = 0.01;
numpulses = 1;
snrthreshold = npwgnthresh(pfa,numpulses,'real')

%%
% Compute fraction of simulated noise samples exceeding the threshold. The
% noise has unit power with 10000 samples.
noisepower = 1;
Ntrial = 10000;
noise = sqrt(noisepower)*randn(1,Ntrial);

%%
% Express the threshold in amplitude units.
threshold = sqrt(noisepower*db2pow(snrthreshold));
calculated_Pfa = sum(noise>threshold)/Ntrial