function [v,sv,mv]=kl_sym(p,q)

%% function [v,sv,mv]=kl(p,q) : Kullback-Leibler distance and various symmetrized forms
%% v = Kullback-Leibler distance
%% sv = symmetrized distance between pdf's
%% mv = sum of distances to mid point
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

p=p(:); q=q(:); p=p+1e-10; q=q+1e-10;
v=p'*log(p)-p'*log(q);
sv=p'*log(p)-p'*log(q) + q'*log(q)-q'*log(p);
m=(p+q)/2;
mv=p'*log(p)-p'*log(m) + q'*log(q)-q'*log(m);