code: def test_em_gmm_diag():
      # Computing the BIC value for GMMs with different number of classes,
      # with diagonal covariance models
      # The BIC should maximal for a number of classes of 1  or 2
  
      # generate some data
      dim = 2
      x = np.concatenate(
          (nr.randn(1000, dim), 3 + 2 * nr.randn(1000, dim))
      )
  
      # estimate different GMMs of that data
      maxiter, delta = 100, 1.0e-8
      prec_type = "diag"
  
      bic = np.zeros(5)
      for k in range(1, 6):
          lgmm = GMM(k, dim, prec_type)
          lgmm.initialize(x)
          bic[k - 1] = lgmm.estimate(x, maxiter, delta)
  
      z = lgmm.map_label(x)
      assert z.max() + 1 == lgmm.k
      assert bic[4] < bic[1]
  
file_path: nipy/nipy/algorithms/clustering/tests/test_gmm.py
imports: import numpy
  from ..gmm import GMM, best_fitting_GMM
label_desc: Use image node_id 10 for calling a global function with example usage: test_em_gmm_diag() without return types