Beispiel #1
0
def test_2():
    # test counts matrix with trimming
    model = MarkovStateModel(n_states=2, reversible_type=None, ergodic_trim=True)

    model.fit([[1,1,1,1,1,1,1,1,1]])
    eq(model.mapping_, {1: 0})
    eq(todense(model.countsmat_), np.array([[8]]))
Beispiel #2
0
def test_3():
    model = MarkovStateModel(n_states=3, reversible_type='mle', ergodic_trim=True)
    model.fit([[0,0,0,0,1,1,1,1,0,0,0,0,2,2,2,2,0,0,0]])

    counts = np.array([[8, 1, 1], [1, 3, 0], [1, 0, 3]])
    eq(todense(model.rawcounts_), counts)
    eq(todense(model.countsmat_), counts)
    model.timescales_

    # test pickleable
    try:
        dump(model, 'test-msm-temp.npy', compress=1)
        model2 = load('test-msm-temp.npy')
        eq(model2.timescales_, model.timescales_)
    finally:
        os.unlink('test-msm-temp.npy')
Beispiel #3
0
def test_5():
    trjs = load_doublewell(random_state=0)['trajectories']
    clusterer = NDGrid(n_bins_per_feature=5)
    mle_msm = MarkovStateModel(lag_time=100, verbose=False)
    b_msm = BayesianMarkovStateModel(
        lag_time=100, n_samples=1000, n_chains=8, n_steps=1000,
        random_state=0)

    states = clusterer.fit_transform(trjs)
    b_msm.fit(states)
    mle_msm.fit(states)

    # this is a pretty silly test. it checks that the mean transition
    # matrix is not so dissimilar from the MLE transition matrix.
    # This shouldn't necessarily be the case anyways -- the likelihood is
    # not "symmetric". And the cutoff chosen is just heuristic.
    assert np.linalg.norm(b_msm.all_transmats_.mean(axis=0) - mle_msm.transmat_) < 1e-3
Beispiel #4
0
def test_1():
    # test counts matrix without trimming
    model = MarkovStateModel(n_states=2, reversible_type=None, ergodic_trim=False)

    model.fit([[1,1,1,1,1,1,1,1,1]])
    eq(todense(model.countsmat_), np.array([[0, 0], [0, 8]]))