def _log_prob(self, counts): counts = self._maybe_assert_valid_sample(counts) ordered_prob = ( special_math_ops.lbeta(self.concentration + counts) - special_math_ops.lbeta(self.concentration)) return ordered_prob + distribution_util.log_combinations( self.total_count, counts)
def _log_prob(self, counts): counts = self._maybe_assert_valid_sample(counts) ordered_prob = ( special_math_ops.lbeta(self.concentration + counts) - special_math_ops.lbeta(self.concentration)) return ordered_prob + distribution_util.log_combinations( self.total_count, counts)
def testLogCombinationsShape(self): # Shape [2, 2] n = [[2, 5], [12, 15]] with self.test_session(): n = np.array(n, dtype=np.float32) # Shape [2, 2, 4] counts = [[[1., 1, 0, 0], [2., 2, 1, 0]], [[4., 4, 1, 3], [10, 1, 1, 4]]] log_binom = distribution_util.log_combinations(n, counts) self.assertEqual([2, 2], log_binom.get_shape())
def testLogCombinationsBinomial(self): n = [2, 5, 12, 15] k = [1, 2, 4, 11] if not special: return log_combs = np.log(special.binom(n, k)) with self.test_session(): n = np.array(n, dtype=np.float32) counts = [[1., 1], [2., 3], [4., 8], [11, 4]] log_binom = distribution_util.log_combinations(n, counts) self.assertEqual([4], log_binom.get_shape()) self.assertAllClose(log_combs, log_binom.eval())
def _log_normalization(self, counts): counts = self._maybe_assert_valid_sample(counts) return -distribution_util.log_combinations(self.total_count, counts)
def _log_normalization(self, counts): counts = self._maybe_assert_valid_sample(counts) return -distribution_util.log_combinations(self.total_count, counts)