Пример #1
0
 def _cdf(self, x):
   logits = self._logits_parameter_no_checks()
   total_count = tf.convert_to_tensor(self.total_count)
   safe_x = tf.where(x >= 0, x, 0.)
   answer = tfp_math.betainc(
       total_count, 1. + safe_x, tf.sigmoid(-logits))
   return distribution_util.extend_cdf_outside_support(x, answer, low=0)
Пример #2
0
 def _cdf(self, x):
   concentration1 = tf.convert_to_tensor(self.concentration1)
   concentration0 = tf.convert_to_tensor(self.concentration0)
   safe_x = tf.where(tf.logical_and(x >= 0, x < 1), x, 0.5)
   answer = tfp_math.betainc(concentration1, concentration0, safe_x)
   return distribution_util.extend_cdf_outside_support(
       x, answer, low=0., high=1.)
 def _cdf(self, x):
     logits = self._logits_parameter_no_checks()
     total_count = tf.convert_to_tensor(self.total_count)
     shape = self._batch_shape_tensor(logits=logits,
                                      total_count=total_count)
     safe_x = tf.where(x >= 0, x, 0.)
     answer = tf.math.betainc(tf.broadcast_to(total_count, shape),
                              tf.broadcast_to(1. + safe_x, shape),
                              tf.broadcast_to(tf.sigmoid(-logits), shape))
     return distribution_util.extend_cdf_outside_support(x, answer, low=0)
Пример #4
0
  def _cdf(self, x):
    concentration1 = tf.convert_to_tensor(self.concentration1)
    concentration0 = tf.convert_to_tensor(self.concentration0)
    shape = functools.reduce(
        ps.broadcast_shape,
        [ps.shape(concentration1),
         ps.shape(concentration0),
         ps.shape(x)])
    concentration1 = tf.broadcast_to(concentration1, shape)
    concentration0 = tf.broadcast_to(concentration0, shape)
    x = tf.broadcast_to(x, shape)

    safe_x = tf.where(tf.logical_and(x >= 0, x < 1), x, 0.5)
    answer = tf.math.betainc(concentration1, concentration0, safe_x)
    return distribution_util.extend_cdf_outside_support(
        x, answer, low=0., high=1.)
Пример #5
0
def _bdtr(k, n, p):
    """The binomial cumulative distribution function.

  Args:
    k: floating point `Tensor`.
    n: floating point `Tensor`.
    p: floating point `Tensor`.

  Returns:
    `sum_{j=0}^k p^j (1 - p)^(n - j)`.
  """
    # Trick for getting safe backprop/gradients into n, k when
    #   betainc(a = 0, ..) = nan
    # Write:
    #   where(unsafe, safe_output, betainc(where(unsafe, safe_input, input)))
    ones = tf.ones_like(n - k)
    safe_dn = tf.where(tf.logical_or(k < 0, k >= n), ones, n - k)
    dk = tfp_math.betainc(a=safe_dn, b=k + 1, x=1 - p)
    return distribution_util.extend_cdf_outside_support(k, dk, low=0, high=n)
Пример #6
0
 def _cdf(self, x):
     # Note that igamma returns the regularized incomplete gamma function,
     # which is what we want for the CDF.
     cdf = tf.math.igamma(self.concentration, self._rate_parameter() * x)
     return distribution_util.extend_cdf_outside_support(x, cdf, low=0.)
Пример #7
0
 def _cdf(self, value):
     cdf = -tf.math.expm1(-self.rate * value)
     # Set cdf = 0 when value is less than 0.
     return distribution_util.extend_cdf_outside_support(value, cdf, low=0.)