% This code can be used to generate the ROC curves for the approximated 
% U_{BF} detector Eq. (28) in Fig. 2 of the paper listed below.
%
% 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 = 50;                                 % Number of samples
Prob_fa_vec = logspace(-3.9, -1, 20)';  % Probability of false alarm
snr_db = -10;                           % SNR value in dB
rho = 0.8;                              % 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 = 4;                           % 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 --
[pd_ana,avg_prob_det] = PdAnalyticalAndSimulation(m_tx, p_rx, K, lp_class, Prob_fa_vec, snr_db, rho, pow_gen);

% -- show results --
figure (2);
loglog(Prob_fa_vec, avg_prob_det,'-k+', Prob_fa_vec, pd_ana,'--k+');
ylim([0.1 1]);
xlabel('Prob of False Alarm');
ylabel('Probabilty of Detection');
legend('Simulation', ' Anaytical','location','southeast');
grid on;


