# # # function [P,Q,A,B,n,p,q]=profile(N) # # Computes profiles of a two way contingency table N # # Input: N # # Output: P (column profiles) # Q (row profiles) # A (number of rows in N) # B (number of columns in N) # n (sum of all entries in N) # p (column vector, average column profile # = sum of rows divided by n) # q (row vector, average row profile # = sum of columns divided by n) # function [P,Q,A,B,n,p,q]=profile(N) [A,B]=size(N); n=sum(sum(N)); p=N*ones(B,1); q=ones(1,A)*N; P=N/diag(q); Q=diag(p)\N; p=p/n; q=q/n; endfunction