<commit_before>#!/usr/bin/python
#
# Calculate the standard deviation of the 
# sampling size experiment
#
############################################

import sys
import re
import math

# Check args
if len(sys.argv) < 2:
	print "Usage " + sys.argv[0] + " <filename>"
        sys.exit(0)

# Regex
samplingSizePattern = re.compile("^Simulating with sample size: ([\d\.]+)");
experimentPattern = re.compile("^(\d+)\s(\d+)\s(\d+)\s\d+\s\d+")


class Experiment(object):

	samplingSize = -1
	leftRegion = []
	totalElements = -1

	def __init__(self, samplingSize):
		self.samplingSize = samplingSize
		self.leftRegion = []
		self. totalElements = -1

	def get_std_str(self):
		'''Error in STD'''
		totalDiff = 0;
		for result in self.leftRegion:
			diff = abs(self.totalElements/2 - result)
			totalDiff = totalDiff + math.pow(diff, 2)

		std = math.sqrt(totalDiff / len(self.leftRegion))
		stdPer = float(std) / float(self.totalElements) * 100.0

		'''Error on AVG'''
		totalDiff = 0;
		for result in self.leftRegion:
			totalDiff = totalDiff + abs(self.totalElements/2 - result)

		average = totalDiff / len(self.leftRegion)
		averagePer = float(average) / float(self.totalElements) * 100.0

		return  self.samplingSize + "\t" + str(stdPer) + "\t" + str(averagePer)

	def __str__(self):<commit_msg>Refactored code<commit_after>#!/usr/bin/python
#
# Calculate the standard deviation of the 
# sampling size experiment
#
############################################

import sys
import re
import math

# Check args
if len(sys.argv) < 2:
	print "Usage:", sys.argv[0], "<filename>"
        sys.exit(0)

# Regex
samplingSizePattern = re.compile("^Simulating with sample size: ([\d\.]+)");
experimentPattern = re.compile("^(\d+)\s(\d+)\s(\d+)\s\d+\s\d+")


class Experiment(object):

	samplingSize = -1
	leftRegion = []
	totalElements = -1

	def __init__(self, samplingSize):
		self.samplingSize = samplingSize
		self.leftRegion = []
		self. totalElements = -1

	def get_std_str(self):
		'''Error in STD'''
		totalDiff = 0;
		for result in self.leftRegion:
			diff = abs(self.totalElements/2 - result)
			totalDiff = totalDiff + math.pow(diff, 2)

		std = math.sqrt(totalDiff / len(self.leftRegion))
		stdPer = float(std) / float(self.totalElements) * 100.0

		'''Error on AVG'''
		totalDiff = 0;
		for result in self.leftRegion:
			totalDiff = totalDiff + abs(self.totalElements/2 - result)

		average = totalDiff / len(self.leftRegion)
		averagePer = float(average) / float(self.totalElements) * 100.0

		return self.samplingSize + "\t" + str(stdPer) + "\t" + str(averagePer)

	def __str__(self):
{'fraction_non_alphanumeric': 0.18199381761978362, 'fraction_numerical': 0.014683153013910355, 'mean_word_length': 3.9314285714285715, 'pattern_counts': {'":': 0, '<': 7, '<?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}}
{'dir': 'git-commits-cleaned', 'id': '767985', 'n_tokens_mistral': 974, 'n_tokens_neox': 869, 'n_words': 208}