% This code can be used to generate the probability of detection vs SNR
% curve for the U_{BF} Eq. (38) detector in Fig. 3 of the paper listed
% below, where the data is complex.
%
% Reference:
% M. H. Al-Ali and K.C. Ho, "Objective Bayesian approach for binary hypothesis
% testing of multivariate Gaussian observations," IEEE Trans. Inf. Theory,
% vol. 69, no. 2, pp. 1337-1354, Feb. 2023.
%
% M. H. Al-Ali and K. C. Ho, Dec. 12. 2022
%
%       Copyright (C) 2022
%       Compputer Engineering Department
%       University of Basrah
%       Basrah Province, Iraq
%       mohannd.khalaf@uobasrah.edu.iq
%
%       Copyright (C) 2022
%       Computational Intelligence Signal Processing Laboratory
%       University of Missouri
%       Columbia, MO 65211, USA.
%       hod@missouri.edu
%

clear all;
rng('default');

% -- simulation parameters --
m_tx = 4;                       % Number of Tx antennas
p_rx = m_tx;                    % Number of Rx antennas
K = 30;                         % Number of samples
Prob_fa = 1e-4;                 % Probability of false alarm
snr_db_vec = [-10:2:10]';       % SNR values in dB
rho = 0.3;                      % Correlation parameter to produce Eq. (40) in the reference paper 
pow_gen = [-2, 1, 0, 0.4]';     % Diagonal values of Omega_0 in the log scale

% -- choice of objective prior for H1 --
lp_class = 5;                   % Index for the objective prior
                                % 1 for Jeffreys Prior
                                % 2 for Independence Jeffreys Prior
                                % 3 for Geisser and Cornfield Prior
                                % 4 for Right Haar Measure
                                % 5 for Reference prior

% -- generate probablity of detection --
avg_prob_det = PdSNR_ComplexData(m_tx, p_rx, K, lp_class, Prob_fa, snr_db_vec, rho, pow_gen);

% -- show results --
figure (3);
plot(snr_db_vec, avg_prob_det,'-black');
xlabel('SNR (dB)');
ylabel('Probability of Detection');
switch lp_class,
    case 1,
        priorName='Jeffreys';
    case 2,
        priorName='Independence Jeffreys';
    case 3,
        priorName='Geisser and Cornfield';
    case 4,
        priorName='Right Haar Measure';
    case 5,
        priorName='Reference';
end;
legend(['Proposed Test (24), \rho = ' num2str(rho) ', ' priorName,' Prior'],'location','southeast');
grid on;

