Jamaine Roseborough

34
reputation
2

Being currently enlisted as A United States Marine, I look to use the next three or more years to developing my programming capabilities. I ultimately plan to become a Data Scientist as a post military career. In the meantime though, I am learning all that I can about machine learning, statistics, and probability. Here is an excerpt of a function I made that finds the variance of a one dimensional data set:

def pop_var(x):
    x = sorted(x)
    num = x

    #creates mean of data set
    mean = sum(num)/len(num)

    '''initializes new data set made up of the
    data points after (Xi-mean)^2 has been ran'''
    new_set = []

    #runs calculation and add it to new_set
    for i in num:
        new_set.append((i - mean)**2)

    #sum of new set divided by N(number of numbers in that set)
    variance = float(sum(new_set))/float(len(new_set))
    return variance