code: def _testSampleConsistentLogProbInterval(
      self,
      concentrations,
      det_bounds,
      dim,
      num_samples=int(1e5),
      dtype=np.float32,
      input_output_cholesky=False,
      false_fail_rate=1e-6,
      target_discrepancy=0.1,
      seed=42,
  ):
      # Consider the set M of dim x dim correlation matrices whose
      # determinant exceeds some bound (rationale for bound forthwith).
      # - This is a (convex!) shape in dim * (dim - 1) / 2 dimensions
      #   (because a correlation matrix is determined by its lower
      #   triangle, and the main diagonal is all 1s).
      # - Further, M is contained entirely in the [-1,1] cube,
      #   because no correlation can fall outside that interval.
      #
      # We have two different ways to estimate the volume of M:
      # - Importance sampling from the LKJ distribution
      # - Importance sampling from the uniform distribution on the cube
      #
      # This test checks that these two methods agree.  However, because
      # the uniform proposal leads to many rejections (thus slowness),
      # those volumes are computed offline and the confidence intervals
      # are presented to this test procedure in the "volume_bounds"
      # table.
      #
      # Why place a lower bound on the determinant?  Because for eta > 1,
      # the density of LKJ approaches 0 as the determinant approaches 0.
      # However, the test methodology requires an upper bound on the
      # improtance weights produced.  Rejecting matrices with too-small
      # determinant (from both methods) allows me to supply that bound.
      #
      # I considered several alternative regions whose volume I might
      # know analytically (without having to do rejection).
      # - Option a: Some hypersphere guaranteed to be contained inside M.
      #   - Con: I don't know a priori how to find a radius for it.
      #   - Con: I still need a lower bound on the determinants that appear
      #     in this sphere, and I don't know how to compute it.
      # - Option b: Some trapezoid given as the convex hull of the
      #   nearly-extreme correlation matrices (i.e., those that partition
      #   the variables into two strongly anti-correclated groups).
      #   - Con: Would have to dig up n-d convex hull code to implement this.
      #   - Con: Need to compute the volume of that convex hull.
      #   - Con: Need a bound on the determinants of the matrices in that hull.
      # - Option c: Same thing, but with the matrices that make a single pair
      #   of variables strongly correlated (or anti-correlated), and leaves
      #   the others uncorrelated.
      #   - Same cons, except that there is a determinant bound (which
      #     felt pretty loose).
      lows = [dtype(volume_bounds[dim][db][0]) for db in det_bounds]
      highs = [dtype(volume_bounds[dim][db][1]) for db in det_bounds]
      concentration = np.array(concentrations, dtype=dtype)
      det_bounds = np.array(det_bounds, dtype=dtype)
      # Due to possible numerical inaccuracies while lower bounding the
      # determinant, the maximum of the importance weights may exceed the
      # theoretical maximum (importance_maxima). We add a tolerance to guard
      # against this. An alternative would have been to add a threshold while
      # filtering in _det_ok_mask, but that would affect the mean as well.
      high_tolerance = 1e-6
  
      testee_dist = lkj.LKJ(
          dimension=dim,
          concentration=concentration,
          input_output_cholesky=input_output_cholesky,
          validate_args=True,
      )
      x = testee_dist.sample(num_samples, seed=seed)
      importance_weights = tf.exp(
          -testee_dist.log_prob(x)
      ) * _det_ok_mask(x, det_bounds, input_output_cholesky)
      importance_maxima = (1.0 / det_bounds) ** (
          concentration - 1
      ) * tf.exp(testee_dist._log_normalization())
      check1 = st.assert_true_mean_in_interval_by_dkwm(
          samples=importance_weights,
          low=0.0,
          high=importance_maxima + high_tolerance,
          expected_low=lows,
          expected_high=highs,
          false_fail_rate=false_fail_rate,
      )
      check2 = assert_util.assert_less(
          st.min_discrepancy_of_true_means_detectable_by_dkwm(
              num_samples,
              low=0.0,
              high=importance_maxima + high_tolerance,
              false_fail_rate=false_fail_rate,
              false_pass_rate=false_fail_rate,
          ),
          dtype(target_discrepancy),
      )
      self.evaluate([check1, check2])
  
imports: from absl.testing import parameterized
  import numpy
  import tensorflow.compat.v1
  import tensorflow.compat.v2
  from tensorflow_probability.python.distributions import lkj
  from tensorflow_probability.python.distributions.internal import statistical_testing
  from tensorflow_probability.python.internal import assert_util
  from tensorflow_probability.python.internal import dtype_util
  from tensorflow_probability.python.internal import test_util
label_desc: Use image node_id 5 for calling the LKJTest obj's underlying member method code with example usage: obj._testSampleConsistentLogProbInterval(concentrations, det_bounds, dim, num_samples, dtype, input_output_cholesky, false_fail_rate, target_discrepancy, seed) without return types