nodes: 0, module; 1, function_definition; 2, function_name:get_histogram; 3, parameters; 4, block; 5, identifier:data; 6, expression_statement; 7, expression_statement; 8, if_statement; 9, expression_statement; 10, expression_statement; 11, expression_statement; 12, expression_statement; 13, expression_statement; 14, for_statement; 15, return_statement; 16, comment:"""Return the histogram relative to the given data
  
      Assume that the data are already sorted
  
      """; 17, assignment; 18, comparison_operator:count < 2; 19, block; 20, assignment; 21, assignment; 22, assignment; 23, assignment; 24, assignment; 25, identifier:value; 26, identifier:data; 27, block; 28, call; 29, identifier:count; 30, call; 31, identifier:count; 32, integer:2; 33, raise_statement; 34, identifier:min_; 35, subscript; 36, identifier:max_; 37, subscript; 38, identifier:std; 39, call; 40, identifier:bins; 41, call; 42, identifier:res; 43, dictionary_comprehension; 44, for_statement; 45, identifier:sorted; 46, argument_list; 47, identifier:len; 48, argument_list; 49, call; 50, identifier:data; 51, integer:0; 52, identifier:data; 53, unary_operator; 54, identifier:stdev; 55, argument_list; 56, identifier:get_histogram_bins; 57, argument_list; 58, pair; 59, for_in_clause; 60, identifier:bin_; 61, identifier:bins; 62, block; 63, call; 64, identifier:data; 65, identifier:StatisticsError; 66, argument_list; 67, integer:1; 68, identifier:data; 69, identifier:min_; 70, identifier:max_; 71, identifier:std; 72, identifier:count; 73, identifier:x; 74, integer:0; 75, identifier:x; 76, identifier:bins; 77, if_statement; 78, identifier:iteritems; 79, argument_list; 80, call; 81, comparison_operator:value <= bin_; 82, block; 83, identifier:res; 84, attribute; 85, argument_list; 86, identifier:value; 87, identifier:bin_; 88, expression_statement; 89, break_statement; 90, string; 91, identifier:format; 92, identifier:count; 93, augmented_assignment; 94, string_content:Too few data points ({}) for get_histogram; 95, subscript; 96, integer:1; 97, identifier:res; 98, identifier:bin_
code: def get_histogram(data):
      """Return the histogram relative to the given data
  
      Assume that the data are already sorted
  
      """
  
      count = len(data)
  
      if count < 2:
          raise StatisticsError('Too few data points ({}) for get_histogram'.format(count))
  
      min_ = data[0]
      max_ = data[-1]
      std = stdev(data)
  
      bins = get_histogram_bins(min_, max_, std, count)
  
      res = {x: 0 for x in bins}
  
      for value in data:
          for bin_ in bins:
              if value <= bin_:
                  res[bin_] += 1
                  break
  
      return sorted(iteritems(res))