Exemplo n.º 1
0
    def log_intensity(self, x: Tensor) -> Tensor:
        r"""
        Logarithm of the intensity (a.k.a. hazard) function.

        The intensity is defined as :math:`\lambda(x) = p(x) / S(x)`.

        The intensity of the Weibull distribution is
        :math:`\lambda(x) = b * k * x^{k - 1}`.
        """
        log_x = x.clip(1e-10, np.inf).log()
        return self.rate.log() + self.shape.log() + (self.shape - 1) * log_x
Exemplo n.º 2
0
    def log_survival(self, x: Tensor) -> Tensor:
        r"""
        Logarithm of the survival function :math:`\log S(x) = \log(1 - CDF(x))`.

        We define :math:`z = (\log(x) - \mu) / \sigma` and obtain the survival
        function as :math:`S(x) = sigmoid(-z)`, or equivalently
        :math:`\log S(x) = -\log(1 + \exp(z))`.
        """
        log_x = x.clip(1e-20, np.inf).log()
        z = (log_x - self.mu) / self.sigma
        F = getF(x)
        return -F.Activation(z, "softrelu")
Exemplo n.º 3
0
    def log_intensity(self, x: Tensor) -> Tensor:
        r"""
        Logarithm of the intensity (a.k.a. hazard) function.

        The intensity is defined as :math:`\lambda(x) = p(x) / S(x)`.

        We define :math:`z = (\log(x) - \mu) / \sigma` and obtain the intensity
        as :math:`\lambda(x) = sigmoid(z) / (\sigma * \log(x))`, or equivalently
        :math:`\log \lambda(x) = z - \log(1 + \exp(z)) - \log(\sigma) - \log(x)`.
        """
        log_x = x.clip(1e-20, np.inf).log()
        z = (log_x - self.mu) / self.sigma
        F = getF(x)
        return z - self.sigma.log() - F.Activation(z, "softrelu") - log_x
Exemplo n.º 4
0
 def f(self, x: Tensor) -> Tensor:
     F = getF(x)
     return F.Activation(x.clip(-100.0, np.inf), act_type="softrelu")
Exemplo n.º 5
0
 def f_inv(self, y: Tensor) -> Tensor:
     return y.clip(-np.inf, 30).exp()
Exemplo n.º 6
0
 def f(self, x: Tensor) -> Tensor:
     return x.clip(1.0e-20, np.inf).log()
Exemplo n.º 7
0
 def log_abs_det_jac(self, x: Tensor, y: Tensor) -> Tensor:
     return y.clip(1.0e-20, np.inf).log()
Exemplo n.º 8
0
 def f_inv(self, y: Tensor) -> Tensor:
     return y.clip(1.0e-20, np.inf).log()
Exemplo n.º 9
0
 def f(self, x: Tensor) -> Tensor:
     return x.clip(-np.inf, 30).exp()