def calc_shs(self, pattern_id): pdata = self._data.patterns[pattern_id] upper = sum(self.__t2(x1, x2) * 2 ** (self.__d1(x1) + self.__d1(x2)) for x1, x2 in combinations(pdata, 2)) +\ sum(self.__d2(x1, x2) * 2 ** (self.__d1(x1) + self.__d1(x2) - 1) for x1, x2 in combinations(pdata, 2)) +\ sum(2 * self.__d1(x) * calc_comb(2 ** (self.__d1(x) - 1), 2) for x in pdata) +\ sum(self.__t1(x) * calc_comb(2 ** self.__d1(x), 2) for x in pdata) bottom = self._data.features_count * sum(2 ** (self.__d1(x1) + self.__d1(x2)) for x1, x2 in combinations(pdata, 2)) +\ self._data.features_count * sum(calc_comb(2 ** self.__d1(x), 2) for x in pdata) return (upper, bottom)
def calc_shs(self, pattern_id): pdata = self._data.patterns[pattern_id] upper = sum( self.__distance(x1, x2) for x1, x2 in combinations(pdata, 2)) bottom = calc_comb(len(pdata), 2) return (upper, bottom)
def calc_shs(self, pattern_id): pdata = self._data.patterns[pattern_id] upper = sum(self.__row_distance2(x1, x2) for x1, x2 in combinations(pdata, 2)) +\ sum(self.__row_distance1(x) for x in pdata) bottom = sum(self.__row_variants(x1) * self.__row_variants(x2) for x1, x2 in combinations(pdata, 2)) +\ sum(calc_comb(self.__row_variants(x), 2) for x in pdata) return (upper, bottom)
def __row_distance1(self, v): result = 0 for i in range(self._data.features_count): result += calc_comb(self.__row_variants(v) / self.__feature_variants(v[i], i), 2) \ * self.__feature_distance2(v[i], v[i], i) result += self.__row_variants(v) * self.__feature_distance1(v[i], i) \ / self.__feature_variants(v[i], i) result = result / self._data.features_count return result
umi_calculations_full)) # s_calculations_reduced = 0 s_calculations_full = 0 sx_calculations_reduced = 0 sx_calculations_full = 0 for i in range(len(patterns_keys)): p_reduced = 0 p_full = 0 for x in data.patterns[patterns_keys[i]]: p_reduced += 1 p_full += calc_variations(x) s_calculations_reduced += commonlib.calc_comb(p_reduced, 2) s_calculations_full += commonlib.calc_comb(p_full, 2) sx_calculations_reduced += p_reduced sx_calculations_full += p_full result.append(('s_calculations_reduced', s_calculations_reduced)) result.append(('s_calculations_full', s_calculations_full)) result.append( ('s_calculations_economy', (s_calculations_full - s_calculations_reduced) / s_calculations_full)) result.append(('sx_calculations_reduced', sx_calculations_reduced)) result.append(('sx_calculations_full', sx_calculations_full)) result.append( ('sx_calculations_economy', (sx_calculations_full - sx_calculations_reduced) / sx_calculations_full))