Created
April 12, 2012 17:32
-
-
Save alexstorer/2369402 to your computer and use it in GitHub Desktop.
Plot the distributions of two gaussians along with a criterion, in the style of decision theory.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function h = plotDecision(dprime,sdnoise,criterion) | |
% h = plotDecision(dprime, sdnoise, criterion) | |
% | |
% plotDecision makes a plot of two Gaussian functions, inspired by signal | |
% detection theory. The inputs are given in terms of standard deviates of | |
% the signal distribution: | |
% | |
% dprime - d', the distance between the means of the Gaussians | |
% sdnoise - $\sigma$, the ratio of the standard deviation of the noise to | |
% the standard deviation of the signal. | |
% criterion - The decision line between the two distributions. In the same | |
% units as d' | |
% | |
% The figure handle h is returned to the user for further manipulations. | |
% Change the settings here for how the gaussians are displayed. | |
xmin = -3; | |
xmax = 3; | |
labelsize = 20; | |
numbersize = 16; | |
criterionlinewidth = 2; | |
doLegend = 1; | |
% Do the plotting! | |
ir = linspace(xmin,xmax,1e6); | |
h = figure(); | |
plot(ir,normpdf(ir,0,1),'b','LineWidth',1); | |
hold on; | |
plot(ir,normpdf(ir,dprime,sdnoise),'r','LineWidth',1); | |
% Rescale the y axis so that you can clearly see the peaks | |
a = axis(); | |
axis([a(1) a(2) a(3) a(4)*1.2]); | |
a = axis(); | |
% Draw the line from top to bottom. | |
l = line([criterion; criterion],[a(3);a(4)]); | |
set(l,'Color','k','LineWidth',criterionlinewidth) | |
hold off | |
% Set the font sizes and other figure options. | |
ax = get(h,'CurrentAxes'); | |
set(ax,'FontSize',numbersize) | |
xlabel('Standard Deviates','FontSize',labelsize) | |
set(ax,'YTickLabel',[]) | |
if doLegend | |
legend('Signal','Noise') | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment