// !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! // ! This script is provided "as is" by Applied Maths. ! // ! You are free to use and modify this script for your own needs. ! // ! Redistribution or reproduction of the script is prohibited. ! // ! DISCLAIMER: ! // ! Improper use of scripts may corrupt your database. ! // ! Running this script is entirely at your own responsibility. ! // ! Applied Maths accepts no lialibility for any consequences ! // ! resulting from its use. ! // !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! //$DISPLAY_COMPWIN integer i,groupnr,maxgroupnr,groupcount[],totcount; float div; string st; if not(CmpIsPresent) then CmpAttach; if not(CmpIsPresent) then { message("There is no comparison present"); stop; } maxgroupnr=0; for i=1 to CmpGetEntryCount do { groupnr=CmpGetGroup(i); if groupnr>maxgroupnr then maxgroupnr=groupnr; if groupnr>0 then { totcount=totcount+1; groupcount[groupnr]=groupcount[groupnr]+1; } } if (totcount<=0) or (maxgroupnr<=0) then { message("There were no groups found"); stop; } if totcount=1 then { message("At least two entries should be in a group"); stop; } st="Group sizes: "; for i=1 to maxgroupnr do if groupcount[i]>0 then { if length(st)>50 then st=st+"~n"; st=st+str(groupcount[i],0,0); if i0 then div=div+groupcount[i]*(groupcount[i]-1); div=1.0-div/(totcount*(totcount-1)); st=st+"~n~nSimpson's index of diversity: "+str(div*100,0,2)+"%"; message(st);