コード例 #1
0
def cov(list_x, list_y):
    sum_of = 0
    for i in range(0, int(zcount.count(list_x))):
        sum_of += ((list_x[i] - zmean.mean(list_x)) *
                   (list_y[i] - zmean.mean(list_y)))
    covar = sum_of / (zcount.count(list_x) - 1)
    return covar
コード例 #2
0
def mean(list_in) -> float:
    if zcount.count(list_in) > 0:
        return sum(list_in) / zcount.count(list_in)
    else:
        print('data set empty')
コード例 #3
0
def median(list_in) -> float:
    median_index = int(zcount.count(list_in) // 2)
    list_in.sort()
    if zcount.count(list_in) % 2 == 0:
        return list_in[median_index] + list_in[median_index - 1] / 2
    return list_in[median_index]
コード例 #4
0
def stderr(list_in) -> float:
    return zstddev.stddev(list_in)/ math.sqrt(zcount.count(list_in))
コード例 #5
0
def variance(list_in) -> float:
    amt_of_nums = zcount.count(list_in)
    mean = zmean.mean(list_in)
    sqaure_dev = [(x - mean) ** 2 for x in list_in]
    return sum(sqaure_dev)/amt_of_nums
コード例 #6
0
f3 = open(
    '/Users/alfonso/PycharmProjects/pythonBasicStats/python-basic-stats-agonzalez1216/dataThree.csv',
    mode='r')


def create_dictionaries(file_dict):
    ret_x_list = list()
    ret_y_list = list()
    for row in file_dict:
        ret_x_list.append(float(row['x']))
        ret_y_list.append(float(row['y']))
    return ret_x_list, ret_y_list


file0_dict = csv.DictReader(f0)
file1_dict = csv.DictReader(f1)
file2_dict = csv.DictReader(f2)
file3_dict = csv.DictReader(f3)
f0x_values, f0y_values = create_dictionaries(file0_dict)
f0x_count = zcount.count(f0x_values)

# print(f0x_values)
# print(f0x_count)
# print(zmean.mean(f0x_values))
# print(zmedian.median(f0x_values))
# print(zvariance.variance(f0x_values))
# print(zstddev.stddev(f0x_values))
# print(zstderr.stderr(f0x_values))
# print(zmode.mode(f0x_values))
print(zcorr.corr(f0x_values, f0y_values))