CHI2CMAT Chi-square distance of cycle matrix. Computes the chi-square distance between the observed cycle matrix Fobs and the expected cycle matrix F. The chi-square distance is defined as chi2 = sum( (N_ij - N*g_ij)^2 ./ (N*g_ij) ); chi2 = chi2cmat(Fobs,F) Fobs = Observation of cycle matrix F = Expected cycle matrix

- f_smctp

Auxiliary function used by ESTSMCTP |

01 function chi2 = chi2cmat(Fobs,F) 02 % CHI2CMAT Chi-square distance of cycle matrix. 03 % 04 % Computes the chi-square distance between the observed 05 % cycle matrix Fobs and the expected cycle matrix F. 06 % 07 % The chi-square distance is defined as 08 % chi2 = sum( (N_ij - N*g_ij)^2 ./ (N*g_ij) ); 09 % 10 % chi2 = chi2cmat(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(F>0); 26 27 % Compute chi-square quantity 28 29 chi2 = sum( (FFobs(FI) - N*FF(FI)).^2 ./ (N*FF(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