www.pudn.com > gmm_utilities.zip > gmm_distance_bhattacharyya.m


function [Bc,Bd] = gmm_distance_bhattacharyya(g1, g2, N) 
 
% Monte Carlo approximation of Bhattacharyya distance. 
% 
% Note: MC integration of the form: integral of p(x)f(x) dx 
% require that p(x) is normalised -- that its integral is 1. 
% In this form, the Bhattacharyya integral is 
%    
%   sqrt(a(x)*b(x)) = a(x)*sqrt(a(x)*b(x))/a(x) 
% 
% So that we have p(x) = a(x) and f(x) = sqrt(a(x)*b(x))/a(x) 
 
s = gmm_samples(g1, N); % use g1 as proposal (ie, as a(x)) 
w1 = gmm_evaluate(g1, s); 
w2 = gmm_evaluate(g2, s); 
 
Bc = sum(sqrt(w1.*w2)./w1) / N; % Bhattacharyya coefficient 
Bd = -log(Bc);