Home > vbmeg > functions > common > utility > vb_kl_distance.m

vb_kl_distance

PURPOSE ^

KL-distance of X and Y

SYNOPSIS ^

function kld = vb_kl_distance(x,y)

DESCRIPTION ^

 KL-distance of X and Y
 KL = vb_kl_distance(X,Y)
 X and Y are normalized before calculation 
 Zero value component is replaced by eps

 2006-8-11 M. Sato

 Copyright (C) 2011, ATR All Rights Reserved.
 License : New BSD License(see VBMEG_LICENSE.txt)

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 function    kld = vb_kl_distance(x,y)
0002 % KL-distance of X and Y
0003 % KL = vb_kl_distance(X,Y)
0004 % X and Y are normalized before calculation
0005 % Zero value component is replaced by eps
0006 %
0007 % 2006-8-11 M. Sato
0008 %
0009 % Copyright (C) 2011, ATR All Rights Reserved.
0010 % License : New BSD License(see VBMEG_LICENSE.txt)
0011 
0012 x = max(x,eps);
0013 y = max(y,eps);
0014 
0015 x = x/sum(x);
0016 y = y/sum(y);
0017 
0018 % KL-divergence
0019 kld = sum( x.*log(x./y) );

Generated on Mon 22-May-2023 06:53:56 by m2html © 2005