Home > wafo > markov > klcmat.m

klcmat

PURPOSE ^

Kullback-Leibler distance of cycle matrix.

SYNOPSIS ^

kl = klcmat(Fobs,F)

DESCRIPTION ^

  KLCMAT  Kullback-Leibler distance of cycle matrix.
 
  comuptes the Kullback-Leibler distance between the observed
    cycle matrix Fobs and the expected cycle matrix F.
 
  The Kullback-Leibler distance is defined as
    K.L. = sum( f_ij * log(N*f_ij/N_ij) )
 
  kl = klcmat(Fobs,F)
 
  Fobs  = Observation of cycle matrix
  F     = Expected cycle matrix

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

01 function kl = klcmat(Fobs,F)
02 % KLCMAT  Kullback-Leibler distance of cycle matrix.
03 %
04 % comuptes the Kullback-Leibler distance between the observed
05 %   cycle matrix Fobs and the expected cycle matrix F.
06 %
07 % The Kullback-Leibler distance is defined as
08 %   K.L. = sum( f_ij * log(N*f_ij/N_ij) )
09 %
10 % kl = klcmat(Fobs,F)
11 %
12 % Fobs  = Observation of cycle matrix
13 % F     = Expected cycle matrix
14 
15 F = flipud(F)';       % Convert to PJ-def
16 Fobs = flipud(Fobs)'; % Convert to PJ-def
17 
18 n = length(F);
19 N = sum(sum(Fobs));
20 
21 F = F / sum(sum(F));
22 
23 FF = F(:);
24 FFobs = Fobs(:);
25 FI = find( (Fobs>0) & (F>0) );
26 
27 % Compute Kullback-Leibler distance
28 
29 kl = sum( FF(FI) .* log(N*F(FI)./Fobs(FI)) );
30 
31

Mathematical Statistics
Centre for Mathematical Sciences
Lund University with Lund Institute of Technology

Comments or corrections to the WAFO group


Generated on Thu 06-Oct-2005 02:21:16 for WAFO by m2html © 2003