Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import math
- import random
- list_1 = [0.6, 0.2, 0.3, 0.2, 0.2, 0.3, 0.2, 0.2, 0.3, 0.2, 0.2, 0.3, 0.2, 0.1, 0.3, 0.3, 0.3]
- list_2 = [0.58, 0.18, 0.28, 0.18, 0.18, 0.28, 0.18, 0.18, 0.28, 0.18, 0.18, 0.28, 0.18, 0.4, 0.6, 0.3, 0.3]
- mean_1 = sum(list_1) / len(list_1)
- mean_2 = sum(list_2) / len(list_2)
- dist_1 = 0
- for i in range(0, len(list_1)) :
- dist_1 += (list_1[i] - 1) * (list_1[i] - 1)
- dist_1 = math.sqrt(dist_1)
- dist_2 = 0
- for i in range(0, len(list_2)) :
- dist_2 += (list_2[i] - 1) * (list_2[i] - 1)
- dist_2 = math.sqrt(dist_2)
- index_list = []
- for i in range(0, len(list_1)):
- index_list.append(i)
- num_of_tests = 5000
- all_mean_1 = 0
- all_mean_2 = 0
- count = 0
- equal_count = 0
- part_size = 3
- for i in range(0, num_of_tests) :
- random.shuffle(index_list)
- mean_1_temp = 0
- mean_2_temp = 0
- for j in range(0, part_size):
- mean_1_temp += list_1[index_list[j]]
- mean_2_temp += list_2[index_list[j]]
- mean_1_temp /= part_size
- mean_2_temp /= part_size
- if mean_1_temp > mean_2_temp :
- count += 1
- else :
- if mean_1_temp == mean_2_temp :
- equal_count+=1
- all_mean_1 += mean_1_temp
- all_mean_2 += mean_2_temp
- all_mean_1 /= num_of_tests
- all_mean_2 /= num_of_tests
- print(mean_1)
- print(mean_2)
- print("------------")
- print((count - equal_count) / (num_of_tests - equal_count))
- print((num_of_tests - count) / (num_of_tests - equal_count))
- print("------------")
- print(all_mean_1)
- print(all_mean_2)
- print("------------")
- print(dist_1)
- print(dist_2)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement