Exemplo n.º 1
0
    def testHMCPropagatorMM(self):

        mm = InvertibleMatrix(np.array([[1., 0.], [0.,  2.]]))
        init_state = State(np.random.normal(size=2))
        gen = HMCPropagator(self.pdf, self.gradient, self.timestep * 1.5, self.nsteps, mass_matrix=mm)

        self.checkResult(gen.generate(init_state, self.nits))
Exemplo n.º 2
0
    def testHMCPropagatorMM(self):

        mm = InvertibleMatrix(np.array([[1., 0.], [0.,  2.]]))
        init_state = State(np.random.normal(size=2))
        gen = HMCPropagator(self.pdf, self.gradient, self.timestep * 1.5, self.nsteps, mass_matrix=mm)

        self.checkResult(gen.generate(init_state, self.nits))
Exemplo n.º 3
0
    def testHMCPropagator(self):

        gen = HMCPropagator(self.pdf, self.gradient, self.timestep,
                            self.nsteps)

        self.checkResult(gen.generate(self.state, self.nits))
Exemplo n.º 4
0
    def testHMCPropagator(self):

        gen = HMCPropagator(self.pdf, self.gradient, self.timestep, self.nsteps)

        self.checkResult(gen.generate(self.state, self.nits))
Exemplo n.º 5
0
        from stuff import numgrad
        g = P.gradient(structures=X.ravel())
        ng = numgrad(X.ravel(), lambda x: -P.log_prob(structures=X))
        print np.max(np.fabs(g - ng))

    from csb.statistics.samplers.mc.propagators import HMCPropagator, MDPropagator
    from csb.statistics.samplers import State

    class MyPDF(object):
        def log_prob(self, x):
            return P.log_prob(structures=x)

        def gradient(self, x, t=0.0):
            return P.gradient(structures=x)

    pdf = MyPDF()
    prop = HMCPropagator(pdf=pdf,
                         gradient=pdf.gradient,
                         timestep=0.15,
                         nsteps=50)
    prop = MDPropagator(gradient=pdf.gradient, timestep=0.01)
    traj = prop.generate(
        State(X.ravel(), np.random.normal(size=X.ravel().shape)), 500, True)

    from ensemble_hic.analysis_functions import write_ensemble
    X = np.array([
        x.position.reshape(n_beads * n_structures,
                           3).reshape(n_structures, -1, 3) for x in traj
    ])
    write_ensemble(X.reshape(-1, n_beads, 3), '/tmp/out.pdb')