Question: how to calculate probability of matrix in this case?

i count the number among group
but when the list a large such as over 1000 records, the count will be over 30,000
use which denominator to find probability?
is there any functions in maple for this case?
 
with(LinearAlgebra):
correlationlist1 := [[1,2,3],[1,3,5]....]:
PAB := Matrix(50):
for ii from 1 to nops(correlationlist) do
 for jj from 1 to nops(correlationlist[ii]) do
  for kk from 1 to nops(correlationlist) do
   for qq from 1 to nops(correlationlist[kk]) do
    if ii <> kk then
     #print("scan=",correlationlist2[kk],"kk=",kk,"qq=",qq,"row=",correlationlist[ii][jj],"column=",correlationlist[kk][qq]):
     PAB[correlationlist[ii][jj],correlationlist[kk][qq]] := PAB[correlationlist[ii][jj],correlationlist[kk][qq]] + 1: # group to group relations
    end if:
   od:
  od:
 od:
od:
Please Wait...