In addition to calculating the joint count statistic, I would like to compare the actual count of joins to the theoretical maximum count of joins. I know how to compute the statistic and find the actual count of joins for a given group (under conditions of two group), but how can I find the theoretical maximum given the known count of members in each group? I would preferably solve this using Python or PostGIS. I am currently using the Pysal module to calculate the joint count statistics. The input data are census tract polygon shapefiles with arbitrary boundaries, making it impossible to simply agglomerate from east to west or north to south, etc.
EDIT: I am asking about the maximum possible count of within-group joins.