class_docstr: Unit tests for metropolis sampling of discrete distributions 
class_docstr_tok: ["Unit","tests","for","metropolis","sampling","of","discrete","distributions"]
docstr: Tests metropolis sampling from Discrete Uniform distribution 
docstr_tok: ["Tests","metropolis","sampling","from","Discrete","Uniform","distribution"]
code: def test_metropolis_discreteuniform(self):
      """Tests metropolis sampling from Discrete Uniform distribution"""
      self.report(
          "Test metropolis sampling of Discrete Uniform Distribution."
      )
      lower = -5
      upper = 5
      dist = DiscreteUniform(lower, upper)
      mean = dist.get_mean()
      var = dist.get_variance()
      samples = dist.draw_samples(
          "metropolis", self.size, np.array([0.1])
      )
      mean_r = self._compute_mean(samples)
      var_r = self._compute_variance(samples)
      self._check_sample_sizes(samples)
      assert (samples >= lower).all() and (samples <= upper).all()
      assert abs(mean - self._compute_mean(samples)) <= self.threshold
      assert (
          abs(var - self._compute_variance(samples)) <= self.threshold
      )
      self.report(
          "%s, mean=%0.3f, variance=%0.3f :: test result: mean=%0.3f, "
          "variance=%0.3f" % (str(dist), mean, var, mean_r, var_r),
          "test_result",
      )
  
file_path: dragonfly/dragonfly/distributions/unittest_metropolis_discrete.py
imports: from __future__ import absolute_import
  import unittest
  import numpy
  from .discrete import DiscreteUniform, Bernoulli
  from ..utils.base_test_class import BaseTestClass, execute_tests
label_desc: Use image node_id 5 for calling the MetropolisDiscreteTestCases obj's underlying member method code with example usage: obj.test_metropolis_discreteuniform() without return types