function [pd, pf, err] = roc(cnt,prob1,prob2) % roc: function which returns the receiver-operating characteristics and % the error rate characterizing the ability of an ideal observer to % discriminate between the two distributions. % % [pd, pf, err] = roc(cnt,prob1,prob2) % % where % cnt = vector of spike counts for both distributions % prob1 = first (null) probability distribution of counts % prob2 = second probability distribution of counts % % The return parameters are: % pd = probability of correct detection % pf = probability of false-alarm % err = error rate % if ( nargin ~= 3 ) disp(' '); disp('usage: roc(cnt,prob1,prob2) '); disp(' for more information type "help roc" in the main'); disp(' matlab window'); disp(' '); return; end; %initializes the various variables prob1 = prob1(:); prob2 = prob2(:); n_cnt = length(cnt); pd = zeros(n_cnt+2,1); pf = zeros(n_cnt+2,1); err = zeros(n_cnt+2,1); for k = 1:n_cnt pf(k+1,1) = sum(prob1(k:n_cnt,1)); pd(k+1,1) = sum(prob2(k:n_cnt,1)); end; pf(1,1) = 1; pd(1,1) = 1; err = 0.5*(pf + 1 - pd);