code: def test_imm_loglike_1D():
      # Check that the log-likelihood of the data under the infinite gaussian
      # mixture model is close to the theoretical data likelihood
      n = 100
      dim = 1
      alpha = 0.5
      x = np.random.randn(n, dim)
      igmm = IMM(alpha, dim)
      igmm.set_priors(x)
  
      # warming
      igmm.sample(x, niter=100)
  
      # sampling
      like = igmm.sample(x, niter=300)
      theoretical_ll = -dim * 0.5 * (1 + np.log(2 * np.pi))
      empirical_ll = np.log(like).mean()
      assert np.absolute(theoretical_ll - empirical_ll) < 0.25 * dim
  
file_path: nipy/nipy/algorithms/clustering/tests/test_imm.py
imports: import numpy
  from numpy.testing import assert_array_equal
  from ..imm import IMM, MixedIMM, co_labelling
label_desc: Use image node_id 2 for calling a global function with example usage: test_imm_loglike_1D() without return types