<commit_before>from random import random
import matplotlib.pyplot as plt

def random_score():
    x = random()
    if x < 0.6: return 0
    if x < 0.8: return 3
    if x < 0.9: return 9
    return 27 

def random_scores(m):
    return [random_score() for ignore_me in range(m)]
    
def mean(x):
    return float(sum(x))/len(x)

def random_means(group_size,number_of_groups):
    return [mean(random_scores(group_size)) for i in range(number_of_groups)]


plt.hist(random_means(500,10000), bins=50)
plt.show()
<commit_msg>Added comments for each function.<commit_after>#!/usr/local/bin/ipython -i
"""
Frequency distribution of random samples (variable size), collected 
random times (variable number of groups), for specified score.
"""
from random import random
import matplotlib.pyplot as plt

# generate 4 scores for specified probability (species rarity weight)
def random_score():
    x = random()
    if x < 0.6: return 0
    if x < 0.8: return 3
    if x < 0.9: return 9
    return 27 

# generate scores for m times (number of species per plot)
def random_scores(m):
    return [random_score() for j in range(m)]

# generic mean calculation function
# used to calculate mean score for sample m
def mean(x):
    return float(sum(x))/len(x)

# generate means of random scores by defining: 
# group size = sample size of species pool
# number of group = number of sampling
def random_means(group_size,number_of_groups):
    return [mean(random_scores(group_size)) for i in range(number_of_groups)]

# generate histogram
plt.hist(random_means(500,10000), bins=50)
plt.show()

{'fraction_non_alphanumeric': 0.10006333122229259, 'fraction_numerical': 0.027232425585813805, 'mean_word_length': 4.180327868852459, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 3, '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}}
{'dir': 'git-commits-cleaned', 'id': '226085', 'n_tokens_mistral': 547, 'n_tokens_neox': 494, 'n_words': 180}