refactored avg_time_frequency to use helper function per_event_time_frequency