Esempio n. 1
0
    def setUpClass(cls):
        super(TestCluster, cls).setUpClass()
        cls.dtraj_dir = tempfile.mkdtemp()

        # generate Gaussian mixture
        means = [
            np.array([-3, 0]),
            np.array([-1, 1]),
            np.array([0, 0]),
            np.array([1, -1]),
            np.array([4, 2])
        ]
        widths = [
            np.array([0.3, 2]),
            np.array([0.3, 2]),
            np.array([0.3, 2]),
            np.array([0.3, 2]),
            np.array([0.3, 2])
        ]
        # continuous trajectory
        nsample = 1000
        cls.T = len(means) * nsample
        cls.X = np.zeros((cls.T, 2))
        for i in range(len(means)):
            cls.X[i * nsample:(i + 1) * nsample,
                  0] = widths[i][0] * np.random.randn() + means[i][0]
            cls.X[i * nsample:(i + 1) * nsample,
                  1] = widths[i][1] * np.random.randn() + means[i][1]
        # cluster in different ways
        cls.km = coor.cluster_kmeans(data=cls.X, k=100)
        cls.rs = coor.cluster_regspace(data=cls.X, dmin=0.5)
        cls.rt = coor.cluster_uniform_time(data=cls.X, k=100)
        cls.cl = [cls.km, cls.rs, cls.rt]
Esempio n. 2
0
    def setUpClass(cls):
        super(TestCluster, cls).setUpClass()
        cls.dtraj_dir = tempfile.mkdtemp()

        # generate Gaussian mixture
        means = [np.array([-3,0]),
                 np.array([-1,1]),
                 np.array([0,0]),
                 np.array([1,-1]),
                 np.array([4,2])]
        widths = [np.array([0.3,2]),
                  np.array([0.3,2]),
                  np.array([0.3,2]),
                  np.array([0.3,2]),
                  np.array([0.3,2])]
        # continuous trajectory
        nsample = 1000
        cls.T = len(means)*nsample
        cls.X = np.zeros((cls.T, 2))
        for i in range(len(means)):
            cls.X[i*nsample:(i+1)*nsample,0] = widths[i][0] * np.random.randn() + means[i][0]
            cls.X[i*nsample:(i+1)*nsample,1] = widths[i][1] * np.random.randn() + means[i][1]
        # cluster in different ways
        cls.km = coor.cluster_kmeans(data = cls.X, k = 100)
        cls.rs = coor.cluster_regspace(data = cls.X, dmin=0.5)
        cls.rt = coor.cluster_uniform_time(data = cls.X, k = 100)
        cls.cl = [cls.km, cls.rs, cls.rt]