docstr: Checks an MVN linear update against the naive dense computation.
docstr_tok: ["Checks","an","MVN","linear","update","against","the","naive","dense","computation","."]
code: def _mvn_linear_update_test_helper(
      self,
      prior_mean,
      prior_scale,
      linear_transformation,
      likelihood_scale,
      observation,
      candidate_posterior_mean,
      candidate_posterior_prec,
      atol=1e-5,
      rtol=1e-7,
  ):
      """Checks an MVN linear update against the naive dense computation."""
  
      # Do the test computation in float64, to ensure numerical stability.
      (
          prior_mean,
          prior_scale,
          linear_transformation,
          likelihood_scale,
          observation,
      ) = [
          tf.cast(t, tf.float64)
          for t in (
              prior_mean,
              prior_scale,
              linear_transformation,
              likelihood_scale,
              observation,
          )
      ]
  
      # Convert scale matrices to precision matrices.
      prior_cov = tf.matmul(prior_scale, prior_scale, adjoint_b=True)
      prior_prec = tf.linalg.inv(prior_cov)
      likelihood_cov = tf.matmul(
          likelihood_scale, likelihood_scale, adjoint_b=True
      )
  
      # Run the regression.
      posterior_prec = prior_prec + tf.matmul(
          linear_transformation,
          tf.linalg.solve(likelihood_cov, linear_transformation),
          adjoint_a=True,
      )
      posterior_mean = tf.linalg.solve(
          posterior_prec,
          (
              tf.linalg.matmul(
                  linear_transformation,
                  tf.linalg.solve(
                      likelihood_cov, observation[..., tf.newaxis]
                  ),
                  adjoint_a=True,
              )
              + tf.linalg.matvec(prior_prec, prior_mean)[
                  ..., tf.newaxis
              ]
          ),
      )[..., 0]
  
      (
          candidate_posterior_mean_,
          candidate_posterior_prec_,
          posterior_mean_,
          posterior_prec_,
      ) = self.evaluate(
          (
              candidate_posterior_mean,
              candidate_posterior_prec,
              tf.cast(posterior_mean, tf.float32),
              tf.cast(posterior_prec, tf.float32),
          )
      )
  
      self.assertAllClose(
          candidate_posterior_mean_,
          posterior_mean_,
          atol=atol,
          rtol=rtol,
      )
      self.assertAllClose(
          candidate_posterior_prec_,
          posterior_prec_,
          atol=atol,
          rtol=rtol,
      )
  
file_path: probability/tensorflow_probability/python/distributions/normal_conjugate_posteriors_test.py
imports: import math
  import tensorflow.compat.v2
  from tensorflow_probability.python.bijectors import fill_scale_tril
  from tensorflow_probability.python.distributions import normal
  from tensorflow_probability.python.distributions import normal_conjugate_posteriors
  from tensorflow_probability.python.internal import test_util
label_desc: Use image node_id 5 for calling the NormalTest obj's underlying member method code with example usage: obj._mvn_linear_update_test_helper(prior_mean, prior_scale, linear_transformation, likelihood_scale, observation, candidate_posterior_mean, candidate_posterior_prec, atol, rtol) without return types