function  Pcorr = xtab2Pcorr(x2)

% XTAB2PCORR -- Probability correct from two-dimensional contingency table.
%
% Pcorr = xtab2Pcorr(x2)
%
% X2 must be a square two-dimensional contingency table produced by XTAB2.
% The function returns a row-vector of Probability{correct} columnwise.
% The diagonal entries in X2 are considered "correct", all else "incorrect".
%
% Examples:  xtab2Pcorr([10 15 ; 10 5])  --> [0.500 0.250]
%            xtab2Pcorr([10 15 ; 10 5]') --> [0.400 0.333]
%
% See also XTAB2, XTAB, DIAG.

% Original coding by Alex Petrov, Ohio State University
% $Revision: 1.0 $  $Date: 2000/10/08 17:40 $
%
% Part of the utils toolbox version 1.1 for MATLAB version 5 and up.
% http://alexpetrov.com/softw/utils/
% Copyright (c) Alexander Petrov 1999-2006, http://alexpetrov.com
% Please read the LICENSE and NO WARRANTY statement in ../utils_license.m

d = diag(x2)' ;          % row-vector of the diagonal elements in the matrix
Pcorr = d ./ sum(x2) ;

%% Return PCORR
%%%%% End of XTAB2PCORR.M
