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
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")
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
def f(self, x: Tensor) -> Tensor: F = getF(x) return F.Activation(x.clip(-100.0, np.inf), act_type="softrelu")
def f_inv(self, y: Tensor) -> Tensor: return y.clip(-np.inf, 30).exp()
def f(self, x: Tensor) -> Tensor: return x.clip(1.0e-20, np.inf).log()
def log_abs_det_jac(self, x: Tensor, y: Tensor) -> Tensor: return y.clip(1.0e-20, np.inf).log()
def f_inv(self, y: Tensor) -> Tensor: return y.clip(1.0e-20, np.inf).log()
def f(self, x: Tensor) -> Tensor: return x.clip(-np.inf, 30).exp()