old_contents: # -*- coding: utf-8 -*-
  
  # The MIT License (MIT)
  
  # Copyright (c) 2014 Baxter S. Eaves Jr,
  # Copyright (c) 2015-2016 MIT Probabilistic Computing Project
  
  # Lead Developer: Feras Saad <fsaad@mit.edu>
  
  # Permission is hereby granted, free of charge, to any person obtaining a
  # copy of this software and associated documentation files (the
  # "Software"), to deal in the Software without restriction, including
  # without limitation the rights to use, copy, modify, merge, publish,
  # distribute, sublicense, and/or sell copies of the Software, and to permit
  # persons to whom the Software is furnished to do so, subject to the
  # following conditions:
  
  # The above copyright notice and this permission notice shall be included
  # in all copies or substantial portions of the Software.
  
  # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
  # OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
  # MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
  # NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
  # DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
  # OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
  # USE OR OTHER DEALINGS IN THE SOFTWARE.
  
  from gpmccc import state
  from gpmcc.utils import general as gu
  
  import numpy as np
  import pylab
  
  n_rows = 300
  n_states = 32
  
  distargs = [ {'K':n_rows} ]
  distargs.extend( [None]*8 )
  cctypes = ['multinomial']
  cctypes.extend(['normal']*8)
  column_names = ['id']
  column_names.extend( ['one cluster']*4 )
  column_names.extend( ['four cluster']*4 )
  
  np.random.seed(10)
  
  # id col
  X = [np.array([i for i in range(n_rows)], dtype=int)]
  
  # four cols of one cluster
  for i in range(4):
      X.append( np.random.randn(n_rows) )
  
  Z = []
  for i in range(n_rows):
      Z.append(np.random.randrange(4))
  
  # four cols of
  for _ in range(4):
      x_clustered = []
      for i in range(n_rows):
          x_clustered.append( np.random.randn()+Z[i]*4 )
  
      X.append(np.array( x_clustered))
  
  states = []
  for s in range(n_states):
      states.append(state.State(X, cctypes, distargs,
          seed=np.random.randrange(200000)))
  
  num_iters = 200
  i = 0
  for state in states:
      i += 1
      state.transition(N=num_iters)
      print "state %i of %i" % (i, n_states)
  
  Zvs = []
  for state in states:
      Zvs.append(state.Zv.tolist())
  
  for Zv in Zvs:
      print Zv
  
  fig = pylab.figure(num=None, figsize=(8,6),
              facecolor='w', edgecolor='k',frameon=False,
              tight_layout=True)
  
  gu.generate_Z_matrix(Zvs, column_names)
  
  # pylab.show()
  
new_contents: # -*- coding: utf-8 -*-
  
  # The MIT License (MIT)
  
  # Copyright (c) 2014 Baxter S. Eaves Jr,
  # Copyright (c) 2015-2016 MIT Probabilistic Computing Project
  
  # Lead Developer: Feras Saad <fsaad@mit.edu>
  
  # Permission is hereby granted, free of charge, to any person obtaining a
  # copy of this software and associated documentation files (the
  # "Software"), to deal in the Software without restriction, including
  # without limitation the rights to use, copy, modify, merge, publish,
  # distribute, sublicense, and/or sell copies of the Software, and to permit
  # persons to whom the Software is furnished to do so, subject to the
  # following conditions:
  
  # The above copyright notice and this permission notice shall be included
  # in all copies or substantial portions of the Software.
  
  # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
  # OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
  # MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
  # NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
  # DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
  # OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
  # USE OR OTHER DEALINGS IN THE SOFTWARE.
  
  import matplotlib.pyplot as plt
  import numpy as np
  import seaborn as sns
  
  from gpmcc.engine import Engine
  from gpmcc.utils import config as cu
  
  np.random.seed(0)
  
  N_ROWS = 300
  N_STATES = 12
  N_ITERS = 50
  
  cctypes = ['categorical(k={})'.format(N_ROWS)] + ['normal']*8
  cctypes, distargs = cu.parse_distargs(cctypes)
  column_names = ['id'] + ['one cluster']*4 + ['four cluster']*4
  
  # id column.
  X = np.zeros((N_ROWS, 9))
  X[:,0] = np.arange(N_ROWS)
  
  # Four columns of one cluster from the standard normal.
  X[:,1:5] = np.random.randn(N_ROWS, 4)
  
  # Four columns of four clusters with unit variance and means \in {0,1,2,3}.
  Z = np.random.randint(4, size=(N_ROWS))
  X[:,5:] = 4*np.reshape(np.repeat(Z,4), (len(Z),4)) + np.random.randn(N_ROWS, 4)
  
  # Inference.
  engine = Engine(X, cctypes, distargs, num_states=N_STATES, initialize=True)
  engine.initialize()
  engine.transition(N=N_ITERS)
  
  # Dependence probability.
  D = engine.dependence_probability_pairwise()
  zmat = sns.clustermap(D, yticklabels=column_names, xticklabels=column_names)
  plt.setp(zmat.ax_heatmap.get_yticklabels(), rotation=0)
  plt.setp(zmat.ax_heatmap.get_xticklabels(), rotation=90)
  plt.show()
  
subject: Write test_id test using dep prob matrix.