code: def test_multinomial():
      """
      test of the generate_multinomial function:
      check that is sums to 1 in a simple case
      """
      n_samples = 100000
      n_classes = 5
      aux = np.reshape(np.random.rand(n_classes), (1, n_classes))
      aux /= aux.sum()
      likelihood = np.repeat(aux, n_samples, 0)
      z = multinomial(likelihood)
      res = np.array([np.sum(z == k) for k in range(n_classes)])
      res = res * 1.0 / n_samples
      assert np.sum((aux - res) ** 2) < 1.0e-4
  
file_path: nipy/nipy/algorithms/clustering/tests/test_bgmm.py
imports: import numpy
  import numpy.random
  from ..bgmm import BGMM, VBGMM, dirichlet_eval, dkl_gaussian, multinomial
label_desc: Use image node_id 2 for calling a global function with example usage: test_multinomial() without return types