code: def distance_law(matrix, log_bins=False):
      
  
      D = np.array([np.average(np.diagonal(matrix, j))
                    for j in range(min(matrix.shape))])
      if not log_bins:
          return D
      else:
          n = min(matrix.shape)
          n_bins = int(np.log(n) / np.log(2) + 1)
          logD = np.array([np.average(D[int(2**(i - 1)):min(n, 2**i)])
                           for i in range(n_bins)])
          return logD
docs: Compute distance law as a function of the genomic coordinate aka P(s).
      Bin length increases exponentially with distance if log_bins is True.