%  Figure 10.3
%
%  Figure caption: Two pairs of normal distributions and the
%  resulting ROC curves.  The left hand side shows the pair of pdfs
%  for N(0,1) (solid) and N(delta, 1) (dashed) and to the Right are
%  the corresponding ROC curves.
%
%  Top delta = 2.  Bottom delta = 1.

deltas = [2, 1]
xValues = -4:0.01:6;

%  Compute PDF and CDF of standard normal.
standardPdfValues = normpdf(xValues, 0, 1);
standardCdfValues = normpdf(xValues, 0, 1);

for i = 1:2

    %  First plot the overlapping PDFs.
    subplot(2, 2, i)
    delta = deltas(i);

    %  Standard Normal.
    plot(xValues, standardPdfValues, '-k', 'LineWdith', 2)
    hold on;

    %  Plus delta.
    pdfValues = normpdf(xValues, delta, 1);
    plot(xValues, pdfValues, '-k', 'LineWidth', 2)

    set(gca, 'Box', 'off', 'FontSize', 18, ...
             'XLim', [-4, 6], 'YLim', [0, 0.4], ...
             'XTick', -4:2:6, 'YTick', [], 'TickDir', 'out')


    %  And now plot the ROC curves.
    subplot(2, 2, i + 1)
    cdfValues = normcdf(xValues, delta, 1)
    plot(1 - standardCDFvalues, 1- cdfValues, '-k', 'LineWidth', 2)
    set(gca, 'Box', 'off', 'FontSize', 18, ...
             'XLim', [-0.02, 1.02], 'Ylim', [-0.02, 1.02], ...
             'YTick', 0:0.2:1, 'XTick', 0:0.2:1, 'TickDir', 'out')
    xlabel('level', 'FontSize', 18)

end

%  Close and set figure position.
set(gcf, 'Position', [200, 100, 1500, 900])