def burt_table(data, variables):
 values = [(var, value) for var in variables for value in var.values]
 table = numpy.zeros((len(values), len(values)))
 counts = [len(attr.values) for attr in variables]
 offsets = numpy.r_[(0, numpy.cumsum(counts))]
 for i in range(len(variables)):
  for j in range((i + 1)):
   var1 = variables[i]
   var2 = variables[j]
   cm = contingency.get_contingency(data, var2, var1)
   (start1, end1) = (offsets[i], (offsets[i] + counts[i]))
   (start2, end2) = (offsets[j], (offsets[j] + counts[j]))
   table[start1:end1, start2:end2] += cm
   if (i != j):
    table[start2:end2, start1:end1] += cm.T
 return (values, table)

def burt_table ( data , variables ) : values = [ ( var , value ) for var in variables for value in var . values ] table = numpy . zeros ( ( len ( values ) , len ( values ) ) ) counts = [ len ( attr . values ) for attr in variables ] offsets = numpy . r_ [ ( 0 , numpy . cumsum ( counts ) ) ] for i in range ( len ( variables ) ) : for j in range ( ( i + 1 ) ) : var1 = variables [ i ] var2 = variables [ j ] cm = contingency . get_contingency ( data , var2 , var1 ) ( start1 , end1 ) = ( offsets [ i ] , ( offsets [ i ] + counts [ i ] ) ) ( start2 , end2 ) = ( offsets [ j ] , ( offsets [ j ] + counts [ j ] ) ) table [ start1 : end1 , start2 : end2 ] += cm if ( i != j ) : table [ start2 : end2 , start1 : end1 ] += cm . T return ( values , table )
construct a burt table for variables .