docstr: ...Test discrete random numbers simulation
          
docstr_tok: ["...","Test","discrete","random","numbers","simulation"]
code: def test_discrete_random(self):
      """...Test discrete random numbers simulation"""
      probabilities = np.array(
          [
              0.11695906,
              0.00584795,
              0.1754386,
              0.29239766,
              0.40935673,
          ]
      )
      # make sure probabilities sum to 1
      probabilities /= np.sum(probabilities)
      n_categories = len(probabilities)
      seeded_sample = [2.0, 3.0, 3.0, 0.0, 4.0]
  
      self._test_dist_with_seed(
          seeded_sample, test_discrete, probabilities, discrete=True
      )
  
      # Statistical tests
      sample = test_discrete(
          probabilities, self.stat_size, self.test_seed
      )
      f_obs = np.array(
          [sum(sample == i) for i in range(n_categories)],
          dtype=float,
      )
      self.assertEqual(
          probabilities.shape,
          f_obs.shape,
          "probability vector and frequency vector "
          "do not have tha same shape! "
          f"n_categories = {n_categories}; "
          f"probabilities.shape = {probabilities.shape}; "
          f"f_obs.shape = {f_obs.shape}. ",
      )
      normalization = np.sum(f_obs)
      f_exp = normalization * probabilities
      self.assertTrue(
          np.allclose(
              np.sum(f_exp), np.sum(f_obs), rtol=1e-8, atol=1e-18
          ),
          "sum  of expected frequencies and of observed frequencies "
          "must agree with relative tolerance 1e-8."
          "This is required by scipy.stats.chisquare . "
          f"np.sum(f_exp) = {np.sum(f_exp)}; "
          f"np.sum(f_obs) = {np.sum(f_obs)}. ",
      )
      p_threshold = 0.05
      _, p = stats.chisquare(f_exp=f_exp, f_obs=f_obs)
      self.assertGreater(
          p,
          p_threshold,
          "Discrete random number generation: "
          "p-value of chi-square test is "
          "smaller than threshold. "
          f"p-value: {p}; "
          f"threshold: {p_threshold}; ",
      )
  
      # Test that variable event with probability 0 never happens
      probabilities_zero = probabilities.copy()
      probabilities_zero[1] = 0
      sample = test_discrete(
          probabilities_zero, self.stat_size, self.test_seed
      )
      self.assertEqual(sum(sample == 1), 0)
  
imports: import unittest
  import multiprocessing
  from multiprocessing.pool import Pool
  import itertools
  import numpy
  import threading
  from scipy import stats
  from tick.random import test_uniform, test_gaussian, test_poisson, test_exponential, test_uniform_int, test_discrete, test_uniform_threaded
label_desc: Use image node_id 11 for calling the Test obj's underlying member method code with example usage: obj.test_discrete_random() without return types