code: def testUnivariateLogConcaveDistributionRejectionSamplerGeometric(
      self,
  ):
      seed = test_util.test_seed()
      n = int(5e5)
  
      probs = np.float32([0.7, 0.8, 0.3, 0.2])
      dist = geometric.Geometric(probs=probs)
      x = discrete_rejection_sampling.log_concave_rejection_sampler(
          mode=dist.mode(),
          prob_fn=dist.prob,
          dtype=dist.dtype,
          sample_shape=[n],
          distribution_minimum=0,
          seed=seed,
      )
  
      x = x + 1  ## scipy.stats.geom is 1-indexed instead of 0-indexed.
      sample_mean, sample_variance = tf.nn.moments(x=x, axes=0)
      [
          sample_mean_,
          sample_variance_,
      ] = self.evaluate(
          [
              sample_mean,
              sample_variance,
          ]
      )
      self.assertAllEqual([4], sample_mean.shape)
      self.assertAllClose(
          stats.geom.mean(probs), sample_mean_, atol=0.0, rtol=0.10
      )
      self.assertAllEqual([4], sample_variance.shape)
      self.assertAllClose(
          stats.geom.var(probs), sample_variance_, atol=0.0, rtol=0.20
      )
  
file_path: probability/tensorflow_probability/python/distributions/discrete_rejection_sampling_test.py
imports: import numpy
  from scipy import stats
  import tensorflow.compat.v2
  from tensorflow_probability.python.distributions import discrete_rejection_sampling
  from tensorflow_probability.python.distributions import geometric
  from tensorflow_probability.python.internal import test_util
label_desc: Use image node_id 1 for calling the DiscreteRejectionSamplingTest obj's underlying member method code with example usage: obj.testUnivariateLogConcaveDistributionRejectionSamplerGeometric() without return types