code: def _statistical_coloring(data):
      """evaluate colors from the indipendence properties of the matrix
      It will encounter problem if one category has all zeros
      """
      data = _normalize_data(data, None)
      categories_levels = _categories_level(list(data.keys()))
      Nlevels = len(categories_levels)
      total = 1.0 * sum(v for v in data.values())
      # count the proportion of observation
      # for each level that has the given name
      # at each level
      levels_count = []
      for level_idx in range(Nlevels):
          proportion = {}
          for level in categories_levels[level_idx]:
              proportion[level] = 0.0
              for key, value in data.items():
                  if level == key[level_idx]:
                      proportion[level] += value
              proportion[level] /= total
          levels_count.append(proportion)
      # for each key I obtain the expected value
      # and it's standard deviation from a binomial distribution
      # under the hipothesys of independence
      expected = {}
      for key, value in data.items():
          base = 1.0
          for i, k in enumerate(key):
              base *= levels_count[i][k]
          expected[key] = base * total, np.sqrt(
              total * base * (1.0 - base)
          )
      # now we have the standard deviation of distance from the
      # expected value for each tile. We create the colors from this
      sigmas = {k: (data[k] - m) / s for k, (m, s) in expected.items()}
      props = {}
      for key, dev in sigmas.items():
          red = 0.0 if dev < 0 else (dev / (1 + dev))
          blue = 0.0 if dev > 0 else (dev / (-1 + dev))
          green = (1.0 - red - blue) / 2.0
          hatch = "x" if dev > 2 else "o" if dev < -2 else ""
          props[key] = {"color": [red, green, blue], "hatch": hatch}
      return props
  
imports: from statsmodels.compat.python import lrange, lzip
  from itertools import product
  import numpy
  from numpy import array, cumsum, iterable, r_
  from pandas import DataFrame
  from statsmodels.graphics import utils
label_desc: Use image node_id 12 for calling a global function with example usage: _statistical_coloring(data) and returns: props