code: def test_vbgmm_select(kmax=6):
      """perform the estimation of a variational gmm + model selection"""
      nr.seed([0])
      n_samples, dim, offset = 100, 3, 2
      x = nr.randn(n_samples, dim)
      x[:30] += offset
      be = -np.inf
      for k in range(1, kmax):
          b = VBGMM(k, dim)
          b.guess_priors(x)
          b.initialize(x)
          b.estimate(x)
          ek = b.evidence(x)
          if ek > be:
              be = ek
              bestk = k
      assert bestk < 3
  
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 9 for calling a global function with example usage: test_vbgmm_select(kmax) without return types