<jupyter_start><jupyter_text>Running Average<jupyter_code>from itertools import accumulate
col = [1,2,3,4,5]
list(accumulate(col))
def running_avg(collection):
    cumsum = accumulate(collection)
    ra = []
    for value in cumsum:
        ra.append(value/(len(ra)+1))
    return ra    
running_avg(col)
cumsum = accumulate(col)
rolling = list(acc/value for value, acc in enumerate(cumsum,1))
rolling<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.12296983758700696, 'fraction_numerical': 0.016241299303944315, 'mean_word_length': 5.352941176470588, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '1', 'dir': 'jupyter-structured-clean-dedup', 'id': '567550', 'license': 'MIT', 'n_tokens_mistral': 158, 'n_tokens_neox': 151, 'n_words': 31, 'path': 'Section 6/6.2-running_average.ipynb', 'repo_name': 'PacktPublishing/The-Modern-Python-Challenge-v-', 'size': '431'}