function [B_g] = fowlkes_mallows_index(lab1,lab2) % FOWLKES_MALLOWS_INDEX - Implements the Fowlkes-Mallows cluster index for various clusterings % % Inputs: % % Written by: % -- % John L. Weatherwax 2008-11-05 % % email: wax@alum.mit.edu % % Please send comments and especially bug reports to the % above email address. % %----- n = length(lab1); N = mk_matching_matrix_N(lab1,lab2); % compute T_g: Nsquared = N.^2; NsquaredSummed = sum(Nsquared(:)); T_g = NsquaredSummed - n; % compute n_{i \dot} n_idot = sum( N, 2 ); % compute n_{\dot j} n_dotj = sum( N, 1 ); % compute P_g: P_g = sum( n_idot.^2 ) - n; % compute Q_g: Q_g = sum( n_dotj.^2 ) - n; % compute B_g: B_g = T_g / sqrt( P_g * Q_g );