code: def binned_mode(a):
      '''Calculate a binned mode of a sample
      
      a - array of values
      
      This routine bins the sample into np.sqrt(len(a)) bins. This is a
      number that is a compromise between fineness of measurement and
      the stochastic nature of counting which roughly scales as the
      square root of the sample size.
      '''
      a = np.asarray(a).flatten()
      a_min = np.min(a)
      a_max = np.max(a)
      n_bins = np.ceil(np.sqrt(len(a)))
      b = ((a - a_min) / (a_max - a_min) * n_bins).astype(int)
      idx = np.argmax(np.bincount(b))
      return np.percentile(a, 100 * float(idx+.5) / n_binsf binned_mode(a):
      '''Calculate a binned mode of a sample
      
      a - array of values
      
      This routine bins the sample into np.sqrt(len(a)) bins. This is a
      number that is a compromise between fineness of measurement and
      the stochastic nature of counting which roughly scales as the
      square root of the sample size.
      '''
      a = np.asarray(a).flatten()
      a_min = np.min(a)
      a_max = np.max(a)
      n_bins = np.ceil(np.sqrt(len(a)))
      b = ((a - a_min) / (a_max - a_min) * n_bins).astype(int)
      idx = np.argmax(np.bincount(b))
      return np.percentile(a, 100 * float(idx+.5) / n_bins)
docs: Calculate a binned mode of a sample
      
      a - array of values
      
      This routine bins the sample into np.sqrt(len(a)) bins. This is a
      number that is a compromise between fineness of measurement and
      the stochastic nature of counting which roughly scales as the
      square root of the sample size.