コード例 #1
0
    def conditional_transition_probability(self, steps, ensemble, force=False):
        """
        This transition's conditional transition probability for a given
        ensemble.

        The conditional transition probability for an ensemble is the
        probability that a path in that ensemble makes the transition from
        state A to state B.

        Parameters
        ----------
        steps : iterable of :class:`.MCStep`
            cycles to analyze
        ensemble : Ensemble
            which ensemble to calculate the CTP for
        force : bool (False)
            if true, cached results are overwritten
        """
        samples = sampleset_sample_generator(steps)
        n_acc = 0
        n_try = 0
        for samp in samples:
            if samp.ensemble is ensemble:
                if self.stateB(samp.trajectory.get_as_proxy(-1)):
                    n_acc += 1
                n_try += 1
        ctp = float(n_acc)/n_try
        logger.info("CTP: " + str(n_acc) + "/" + str(n_try) + "=" + str(ctp)
                    + "\n")
        try:
            self.ctp[ensemble] = ctp
        except AttributeError:
            self.ctp = { ensemble : ctp }

        return ctp
コード例 #2
0
 def all_statistics(self, steps, weights=None, force=False):
     """
     Run all statistics for all ensembles.
     """
     # TODO: speed this up by just running over all samples once and
     # dealing them out to the appropriate histograms
     for ens in self.ensembles:
         samples = sampleset_sample_generator(steps)
         self.ensemble_statistics(ens, samples, weights, force)