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)
Ejemplo n.º 3
0
    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())
Ejemplo n.º 4
0
    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())
Ejemplo n.º 5
0
 def _log_normalization(self, counts):
     counts = self._maybe_assert_valid_sample(counts)
     return -distribution_util.log_combinations(self.total_count, counts)
Ejemplo n.º 6
0
 def _log_normalization(self, counts):
   counts = self._maybe_assert_valid_sample(counts)
   return -distribution_util.log_combinations(self.total_count, counts)