class_docstr: Generic histogram class for real numbers
  
  Example:
  
      >>> h = Histogram(5)     # Initializing, bin width = 5
      >>> h << [2,3,2,7,8,5,5,0,7,9]     # Adding more items
      >>> print(h)
      N = 10, mean +- sd: 4.8000 +- 2.9740
      [ 0,  5): **** (4)
      [ 5, 10): ****** (6)
docstr: Returns the string representation of the histogram.
  
  @param max_width: the maximal width of each line of the string
    This value may not be obeyed if it is too small.
  @param show_bars: specify whether the histogram bars should be shown
  @param show_counts: specify whether the histogram counts should be
    shown. If both I{show_bars} and I{show_counts} are C{False},
    only a general descriptive statistics (number of elements, mean and
    standard deviation) is shown.
docstr_tok: ["Returns","the","string","representation","of","the","histogram",".","@","param","max_width",":","the","maximal","width","of","each","line","of","the","string","This","value","may","not","be","obeyed","if","it","is","too","small",".","@","param","show_bars",":","specify","whether","the","histogram","bars","should","be","shown","@","param","show_counts",":","specify","whether","the","histogram","counts","should","be","shown",".","If","both","I","{","show_bars","}","and","I","{","show_counts","}","are","C","{","False","}",",","only","a","general","descriptive","statistics","(","number","of","elements",",","mean","and","standard","deviation",")","is","shown","."]
code: def to_string(self, max_width=78, show_bars=True, show_counts=True):
      """Returns the string representation of the histogram.
  
      @param max_width: the maximal width of each line of the string
        This value may not be obeyed if it is too small.
      @param show_bars: specify whether the histogram bars should be shown
      @param show_counts: specify whether the histogram counts should be
        shown. If both I{show_bars} and I{show_counts} are C{False},
        only a general descriptive statistics (number of elements, mean and
        standard deviation) is shown.
      """
  
      if self._min is None or self._max is None:
          return "N = 0"
  
      # Determine how many decimal digits should we use
      if (
          int(self._min) == self._min
          and int(self._bin_width) == self._bin_width
      ):
          number_format = "%d"
      else:
          number_format = "%.3f"
      num_length = max(
          len(number_format % self._min), len(number_format % self._max)
      )
      number_format = "%" + str(num_length) + number_format[1:]
      format_string = "[%s, %s): %%s" % (number_format, number_format)
  
      # Calculate the scale of the bars on the histogram
      if show_bars:
          maxval = max(self._bins)
          if show_counts:
              maxval_length = len(str(maxval))
              scale = maxval // (
                  max_width - 2 * num_length - maxval_length - 9
              )
          else:
              scale = maxval // (max_width - 2 * num_length - 6)
          scale = max(scale, 1)
  
      result = [
          "N = %d, mean +- sd: %.4f +- %.4f"
          % (self.n, self.mean, self.sd)
      ]
  
      if show_bars:
          # Print the bars
          if scale > 1:
              result.append("Each * represents %d items" % scale)
          if show_counts:
              format_string += " (%d)"
              for left, right, cnt in self.bins():
                  result.append(
                      format_string
                      % (left, right, "*" * (cnt // scale), cnt)
                  )
          else:
              for left, right, cnt in self.bins():
                  result.append(
                      format_string
                      % (left, right, "*" * (cnt // scale))
                  )
      elif show_counts:
          # Print the counts only
          for left, right, cnt in self.bins():
              result.append(format_string % (left, right, cnt))
  
      return "\n".join(result)
  
imports: import math
label_desc: Use image node_id 12 for calling the Histogram obj's underlying member method code with example usage: obj.to_string(max_width, show_bars, show_counts) and returns: str, str