code: def test_evidence(k=1):
      """
      Compare the evidence estimated by Chib's method
      with the variational evidence (free energy)
      fixme : this one really takes time
      """
      np.random.seed(0)
      n_samples, dim, offset = 50, 2, 3
      x = nr.randn(n_samples, dim)
      x[:15] += offset
  
      b = VBGMM(k, dim)
      b.guess_priors(x)
      b.initialize(x)
      b.estimate(x)
      vbe = b.evidence(x)
  
      niter = 1000
      b = BGMM(k, dim)
      b.guess_priors(x)
      b.initialize(x)
      b.sample(x, 100)
      w, cent, prec, pz = b.sample(x, niter=niter, mem=1)
      bplugin = BGMM(k, dim, cent, prec, w)
      bplugin.guess_priors(x)
      bfchib = bplugin.bayes_factor(x, pz.astype(np.int_), 1)
  
      assert bfchib > vbe
  
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 10 for calling a global function with example usage: test_evidence(k) without return types