%
%  this file constructs an ROC curve for the
%  sinus rhythm - ventricular tachycardia data
%
%  load all of the SR data
%
  load pt2_sr
  load pt4_sr
  load pt5_sr
  load pt9_sr
  sr = [pt2_sr pt4_sr pt5_sr pt9_sr];
%
%  load all of the VT data
%
  load pt2_vt
  load pt4_vt
  load pt5_vt
  load pt9_vt
   vt = [pt2_vt pt4_vt pt5_vt pt9_vt];
%
%  now sort the data from smallest to largest, not
%  necessary but lots of fun anyway
%
  sr = sort(sr);
  N_sr = length(sr);
  vt = sort(vt);
  N_vt = length(vt);
%
%  save this data
%
   save ROC_cc_laptop_noslide_sr sr -ascii
   save ROC_cc_laptop_noslide_vt vt -ascii
%
%  may want to load it later, if you didn't overwrite it!
%
%  load ROC_cc_laptop_noslide_sr
%  load ROC_cc_laptop_noslide_vt
%
%  now construct the ROC curve
%
  N = 1000;
  gamma = linspace(0,1,N);
  Pd = zeros(1,N); Pf = zeros(1,N);
  for k = 1:N
  end;
  
  Pf_1 = Pf(floor(0.8*N));
  Pd_1 = Pd(floor(0.8*N));
  v_1 = gamma(floor(0.8*N));
  
  Pf_2 = Pf(floor(0.85*N));
  Pd_2 = Pd(floor(0.85*N));
  v_2 = gamma(floor(0.85*N));
  
  Pf_3 = Pf(floor(0.9*N));
  Pd_3 = Pd(floor(0.9*N));
  v_3 = gamma(floor(0.9*N));
  
  Pf_4 = Pf(floor(0.95*N));
  Pd_4 = Pd(floor(0.95*N));
  v_4 = gamma(floor(0.95*N));
  
%
%  estimate the area under the curve
%
  area = 0;
  for i = 2:N
  end;
%  
%   figure;
%   plot(Pf,Pd,'-',Pf_1,Pd_1,'d',Pf_2,Pd_2,'s',Pf_3,Pd_3,'o',Pf_4,Pd_4,'*'); 
%   axis([0 1 0 1]);
%   legend('ROC',['\gamma = ' num2str(v_1,2)],['\gamma = ' num2str(v_2,2)], ...
%       ['\gamma = ' num2str(v_3,2)], ['\gamma = ' num2str(v_4,2)]); 
%   grid; xlabel('Probability of False Alarm');
%   ylabel('Probability of Detection');
%   title(['ROC curve for SR vs. VT, area under curve = ',num2str(area)]);