

def fit_lds_model(Xs, Xtest, N_samples=100):
    model = MultinomialLDS(K, D, init_dynamics_distn=Gaussian(mu_0=np.zeros(D), sigma_0=np.eye(D), kappa_0=1.0, nu_0=(D + 1.0)), dynamics_distn=AutoRegression(nu_0=(D + 1), S_0=np.eye(D), M_0=np.zeros((D, D)), K_0=np.eye(D)), sigma_C=1)
    for X in Xs:
        model.add_data(X)
    data = model.data_list[0]
    samples = []
    lls = []
    test_lls = []
    mc_test_lls = []
    pis = []
    psis = []
    zs = []
    timestamps = [time.time()]
    for smpl in progprint_xrange(N_samples):
        model.resample_model()
        timestamps.append(time.time())
        samples.append(model.copy_sample())
        lls.append(model.log_likelihood())
        mc_test_lls.append(model._mc_heldout_log_likelihood(Xtest, M=1)[0])
        pis.append(model.pi(data))
        psis.append(model.psi(data))
        zs.append(data['states'].stateseq)
    lls = np.array(lls)
    test_lls = np.array(test_lls)
    pis = np.array(pis)
    psis = np.array(psis)
    zs = np.array(zs)
    timestamps = np.array(timestamps)
    timestamps -= timestamps[0]
    return (model, lls, test_lls, mc_test_lls, pis, psis, zs, timestamps)

dataset/ETHPy150Open HIPS/pgmult/examples/multinomial_lds_2.py fit_lds_model/original