(stat_dict, print_interval_stats=True)
return return_str
Makes string of interesting statistics from a composition stat_dict.

  Args:
    stat_dict: A dictionary storing statistics about a series of compositions.
    print_interval_stats: If True, print additional stats about the number of
      different intervals types.
  Returns:
    String containing several lines of formatted stats.
Makes string of interesting statistics from a composition stat_dict.
Makes string of interesting statistics from a composition stat_dict .
def get_stat_dict_string(stat_dict, print_interval_stats=True):
  """Makes string of interesting statistics from a composition stat_dict.

  Args:
    stat_dict: A dictionary storing statistics about a series of compositions.
    print_interval_stats: If True, print additional stats about the number of
      different intervals types.
  Returns:
    String containing several lines of formatted stats.
  """
  tot_notes = float(stat_dict['total_notes'])
  tot_comps = float(stat_dict['num_compositions'])

  return_str = 'Total compositions: ' + str(tot_comps) + '\n'
  return_str += 'Total notes:' + str(tot_notes) + '\n'

  return_str += '\tCompositions starting with tonic: '
  return_str += str(float(stat_dict['num_starting_tonic'])) + '\n'
  return_str += '\tCompositions with unique highest note:'
  return_str += str(float(stat_dict['num_high_unique'])) + '\n'
  return_str += '\tCompositions with unique lowest note:'
  return_str += str(float(stat_dict['num_low_unique'])) + '\n'
  return_str += '\tNumber of resolved leaps:'
  return_str += str(float(stat_dict['num_resolved_leaps'])) + '\n'
  return_str += '\tNumber of double leaps:'
  return_str += str(float(stat_dict['num_leap_twice'])) + '\n'
  return_str += '\tNotes not in key:' + str(float(
      stat_dict['notes_not_in_key'])) + '\n'
  return_str += '\tNotes in motif:' + str(float(
      stat_dict['notes_in_motif'])) + '\n'
  return_str += '\tNotes in repeated motif:'
  return_str += str(float(stat_dict['notes_in_repeated_motif'])) + '\n'
  return_str += '\tNotes excessively repeated:'
  return_str += str(float(stat_dict['num_repeated_notes'])) + '\n'
  return_str += '\n'

  num_resolved = float(stat_dict['num_resolved_leaps'])
  total_leaps = (float(stat_dict['num_leap_twice']) + num_resolved)
  if total_leaps > 0:
    percent_leaps_resolved = num_resolved / total_leaps
  else:
    percent_leaps_resolved = np.nan
  return_str += '\tPercent compositions starting with tonic:'
  return_str += str(stat_dict['num_starting_tonic'] / tot_comps) + '\n'
  return_str += '\tPercent compositions with unique highest note:'
  return_str += str(float(stat_dict['num_high_unique']) / tot_comps) + '\n'
  return_str += '\tPercent compositions with unique lowest note:'
  return_str += str(float(stat_dict['num_low_unique']) / tot_comps) + '\n'
  return_str += '\tPercent of leaps resolved:'
  return_str += str(percent_leaps_resolved) + '\n'
  return_str += '\tPercent notes not in key:'
  return_str += str(float(stat_dict['notes_not_in_key']) / tot_notes) + '\n'
  return_str += '\tPercent notes in motif:'
  return_str += str(float(stat_dict['notes_in_motif']) / tot_notes) + '\n'
  return_str += '\tPercent notes in repeated motif:'
  return_str += str(stat_dict['notes_in_repeated_motif'] / tot_notes) + '\n'
  return_str += '\tPercent notes excessively repeated:'
  return_str += str(stat_dict['num_repeated_notes'] / tot_notes) + '\n'
  return_str += '\n'

  for lag in [1, 2, 3]:
    avg_autocorr = np.nanmean(stat_dict['autocorrelation' + str(lag)])
    return_str += '\tAverage autocorrelation of lag' + str(lag) + ':'
    return_str += str(avg_autocorr) + '\n'

  if print_interval_stats:
    return_str += '\n'
    return_str += '\tAvg. num octave jumps per composition:'
    return_str += str(float(stat_dict['num_octave_jumps']) / tot_comps) + '\n'
    return_str += '\tAvg. num sevenths per composition:'
    return_str += str(float(stat_dict['num_sevenths']) / tot_comps) + '\n'
    return_str += '\tAvg. num fifths per composition:'
    return_str += str(float(stat_dict['num_fifths']) / tot_comps) + '\n'
    return_str += '\tAvg. num sixths per composition:'
    return_str += str(float(stat_dict['num_sixths']) / tot_comps) + '\n'
    return_str += '\tAvg. num fourths per composition:'
    return_str += str(float(stat_dict['num_fourths']) / tot_comps) + '\n'
    return_str += '\tAvg. num rest intervals per composition:'
    return_str += str(float(stat_dict['num_rest_intervals']) / tot_comps)
    return_str += '\n'
    return_str += '\tAvg. num seconds per composition:'
    return_str += str(float(stat_dict['num_seconds']) / tot_comps) + '\n'
    return_str += '\tAvg. num thirds per composition:'
    return_str += str(float(stat_dict['num_thirds']) / tot_comps) + '\n'
    return_str += '\tAvg. num in key preferred intervals per composition:'
    return_str += str(
        float(stat_dict['num_in_key_preferred_intervals']) / tot_comps) + '\n'
    return_str += '\tAvg. num special rest intervals per composition:'
    return_str += str(
        float(stat_dict['num_special_rest_intervals']) / tot_comps) + '\n'
  return_str += '\n'

  return return_str
def get_stat_dict_string ( stat_dict , print_interval_stats = True ) : tot_notes = float ( stat_dict [ 'total_notes' ] ) tot_comps = float ( stat_dict [ 'num_compositions' ] ) return_str = 'Total compositions: ' + str ( tot_comps ) + '\n' return_str += 'Total notes:' + str ( tot_notes ) + '\n' return_str += '\tCompositions starting with tonic: ' return_str += str ( float ( stat_dict [ 'num_starting_tonic' ] ) ) + '\n' return_str += '\tCompositions with unique highest note:' return_str += str ( float ( stat_dict [ 'num_high_unique' ] ) ) + '\n' return_str += '\tCompositions with unique lowest note:' return_str += str ( float ( stat_dict [ 'num_low_unique' ] ) ) + '\n' return_str += '\tNumber of resolved leaps:' return_str += str ( float ( stat_dict [ 'num_resolved_leaps' ] ) ) + '\n' return_str += '\tNumber of double leaps:' return_str += str ( float ( stat_dict [ 'num_leap_twice' ] ) ) + '\n' return_str += '\tNotes not in key:' + str ( float ( stat_dict [ 'notes_not_in_key' ] ) ) + '\n' return_str += '\tNotes in motif:' + str ( float ( stat_dict [ 'notes_in_motif' ] ) ) + '\n' return_str += '\tNotes in repeated motif:' return_str += str ( float ( stat_dict [ 'notes_in_repeated_motif' ] ) ) + '\n' return_str += '\tNotes excessively repeated:' return_str += str ( float ( stat_dict [ 'num_repeated_notes' ] ) ) + '\n' return_str += '\n' num_resolved = float ( stat_dict [ 'num_resolved_leaps' ] ) total_leaps = ( float ( stat_dict [ 'num_leap_twice' ] ) + num_resolved ) if total_leaps > 0 : percent_leaps_resolved = num_resolved / total_leaps else : percent_leaps_resolved = np . nan return_str += '\tPercent compositions starting with tonic:' return_str += str ( stat_dict [ 'num_starting_tonic' ] / tot_comps ) + '\n' return_str += '\tPercent compositions with unique highest note:' return_str += str ( float ( stat_dict [ 'num_high_unique' ] ) / tot_comps ) + '\n' return_str += '\tPercent compositions with unique lowest note:' return_str += str ( float ( stat_dict [ 'num_low_unique' ] ) / tot_comps ) + '\n' return_str += '\tPercent of leaps resolved:' return_str += str ( percent_leaps_resolved ) + '\n' return_str += '\tPercent notes not in key:' return_str += str ( float ( stat_dict [ 'notes_not_in_key' ] ) / tot_notes ) + '\n' return_str += '\tPercent notes in motif:' return_str += str ( float ( stat_dict [ 'notes_in_motif' ] ) / tot_notes ) + '\n' return_str += '\tPercent notes in repeated motif:' return_str += str ( stat_dict [ 'notes_in_repeated_motif' ] / tot_notes ) + '\n' return_str += '\tPercent notes excessively repeated:' return_str += str ( stat_dict [ 'num_repeated_notes' ] / tot_notes ) + '\n' return_str += '\n' for lag in [ 1 , 2 , 3 ] : avg_autocorr = np . nanmean ( stat_dict [ 'autocorrelation' + str ( lag ) ] ) return_str += '\tAverage autocorrelation of lag' + str ( lag ) + ':' return_str += str ( avg_autocorr ) + '\n' if print_interval_stats : return_str += '\n' return_str += '\tAvg. num octave jumps per composition:' return_str += str ( float ( stat_dict [ 'num_octave_jumps' ] ) / tot_comps ) + '\n' return_str += '\tAvg. num sevenths per composition:' return_str += str ( float ( stat_dict [ 'num_sevenths' ] ) / tot_comps ) + '\n' return_str += '\tAvg. num fifths per composition:' return_str += str ( float ( stat_dict [ 'num_fifths' ] ) / tot_comps ) + '\n' return_str += '\tAvg. num sixths per composition:' return_str += str ( float ( stat_dict [ 'num_sixths' ] ) / tot_comps ) + '\n' return_str += '\tAvg. num fourths per composition:' return_str += str ( float ( stat_dict [ 'num_fourths' ] ) / tot_comps ) + '\n' return_str += '\tAvg. num rest intervals per composition:' return_str += str ( float ( stat_dict [ 'num_rest_intervals' ] ) / tot_comps ) return_str += '\n' return_str += '\tAvg. num seconds per composition:' return_str += str ( float ( stat_dict [ 'num_seconds' ] ) / tot_comps ) + '\n' return_str += '\tAvg. num thirds per composition:' return_str += str ( float ( stat_dict [ 'num_thirds' ] ) / tot_comps ) + '\n' return_str += '\tAvg. num in key preferred intervals per composition:' return_str += str ( float ( stat_dict [ 'num_in_key_preferred_intervals' ] ) / tot_comps ) + '\n' return_str += '\tAvg. num special rest intervals per composition:' return_str += str ( float ( stat_dict [ 'num_special_rest_intervals' ] ) / tot_comps ) + '\n' return_str += '\n' return return_str