Exemplo n.º 1
0
 def _variance(self):
     if distribution_util.is_diagonal_scale(self.scale):
         return 2. * math_ops.square(self.scale.diag_part())
     elif (isinstance(self.scale, linalg.LinearOperatorLowRankUpdate)
           and self.scale.is_self_adjoint):
         return array_ops.matrix_diag_part(
             2. * self.scale.matmul(self.scale.to_dense()))
     else:
         return 2. * array_ops.matrix_diag_part(
             self.scale.matmul(self.scale.to_dense(), adjoint_arg=True))
Exemplo n.º 2
0
 def _covariance(self):
   # Let
   #   W = (w1,...,wk), with wj ~ iid Exponential(0, 1).
   # Then this distribution is
   #   X = loc + LW,
   # and then since Cov(wi, wj) = 1 if i=j, and 0 otherwise,
   #   Cov(X) = L Cov(W W^T) L^T = L L^T.
   if distribution_util.is_diagonal_scale(self.scale):
     return array_ops.matrix_diag(math_ops.square(self.scale.diag_part()))
   else:
     return self.scale.matmul(self.scale.to_dense(), adjoint_arg=True)
Exemplo n.º 3
0
 def _covariance(self):
     # Let
     #   W = (w1,...,wk), with wj ~ iid Laplace(0, 1).
     # Then this distribution is
     #   X = loc + LW,
     # and since E[X] = loc,
     #   Cov(X) = E[LW W^T L^T] = L E[W W^T] L^T.
     # Since E[wi wj] = 0 if i != j, and 2 if i == j, we have
     #   Cov(X) = 2 LL^T
     if distribution_util.is_diagonal_scale(self.scale):
         return 2. * array_ops.matrix_diag(
             math_ops.square(self.scale.diag_part()))
     else:
         return 2. * self.scale.matmul(self.scale.to_dense(),
                                       adjoint_arg=True)