nrow=30; ncol=5; % Fix the marginals of the two rows nrowt=200*ones(1,nrow); % Fix the marginals of the three columns ncolt=1200*ones(ncol,1); % Generate the contingency table out=rcontFS(nrow,ncol,nrowt,ncolt); N=out.m144; MU=sum(N,1)/sum(nrowt); % Compute MD ; n=sum(N,'all'); P=N/n; ProfileRows=P./sum(P,1); d=mahalCorAna(ProfileRows,MU);
nrow=30; ncol=5; % Fix the marginals of the two rows nrowt=200*ones(1,nrow); % Fix the marginals of the three columns ncolt=1200*ones(ncol,1); % Generate the contingency table out=rcontFS(nrow,ncol,nrowt,ncolt); N=out.m144; n=sum(N,'all'); P=N/n; r=sum(P,2); % row masses c=sum(P,1); % centroid of row masses ProfileRows=P./r; d2=r.*mahalCorAna(ProfileRows,c); % d2 is the total inertia disp('Total inertia') disp(sum(d2));