text: from __future__ import division
  import numpy as np
  import matplotlib.pyplot as plt
  import seaborn
  
  import cProfile
  import bayesian_changepoint_detection.offline_changepoint_detection as offcd
  import bayesian_changepoint_detection.generate_data as gd
  from functools import partial
  
  if __name__ == '__main__':
    show_plot = True
    dim = 4
    if dim == 1:
      partition, data = gd.generate_normal_time_series(7, 50, 200)
    else:
      partition, data = gd.generate_multinormal_time_series(7, dim, 50, 200)
    changes = np.cumsum(partition)
  
    if show_plot:
      fig, ax = plt.subplots(figsize=[16,12])
      for p in changes:
        ax.plot([p,p],[np.min(data),np.max(data)],'r')
      for d in range(dim):
        ax.plot(data[:,d])
      plt.show()
  
  
    #Q, P, Pcp = offcd.offline_changepoint_detection(data,partial(offcd.const_prior, l=(len(data)+1)),offcd.gaussian_obs_log_likelihood, truncate=-20)
    #Q_ifm, P_ifm, Pcp_ifm = offcd.offline_changepoint_detection(data,partial(offcd.const_prior, l=(len(data)+1)),offcd.ifm_obs_log_likelihood,truncate=-20)
    Q_full, P_full, Pcp_full = offcd.offline_changepoint_detection(data,partial(offcd.const_prior, l=(len(data)+1)),offcd.fullcov_obs_log_likelihood, truncate=-50)
  
    if show_plot:
      fig, ax = plt.subplots(figsize=[18, 16])
      ax = fig.add_subplot(2, 1, 1)
      for p in changes:
        ax.plot([p,p],[np.min(data),np.max(data)],'r')
      for d in range(dim):
        ax.plot(data[:,d])
      ax = fig.add_subplot(2, 1, 2, sharex=ax)
      ax.plot(np.exp(Pcp_full).sum(0))
      plt.show()
  
  