def test_generate_data(self):

        if self.comm.Get_rank() == 0:
            self.mu = [np.repeat(np.double(k), self.d) for k in range(self.K)]
            r = np.zeros(self.d)
            r[0] = 3.
            r[1] = -1
            self.sigma = [spl.toeplitz(r) for k in range(self.K)]

            self.data_sigma = [[
                invwishartrand(5, self.sigma[k]) for k in range(self.K)
            ] for n in range(self.n)]  # @UnusedVariable
            self.data_mu = [[
                self.mu[k] + np.random.randn(self.d) * 0.2
                for k in range(self.K)
            ] for n in range(self.n)]  # @UnusedVariable
            self.Y = []
            for i in range(self.n):
                mix = mixture(K=self.K)
                mix.mu = self.data_mu[i]
                mix.sigma = self.data_sigma[i]
                mix.p = np.ones(self.K) / self.K
                mix.d = self.d
                self.Y.append(mix.simulate_data(self.n_obs))
        else:
            self.Y = None
        self.hGMM.set_data(self.Y)
        self.hGMM.set_prior_param0()
	def setdata(self):
		
		self.mu = [np.repeat(np.double(k),self.d) for k in range(self.K)]
		self.r1 =  np.zeros(self.d)
		self.r1[0] = 3.
		self.r1[1] = -1
		self.r1[2] = 1
		self.r1[2] = .5
		self.r2 =  np.zeros(self.d)
		self.r2[0] = 2.
		self.r2[1] = -1.5
		self.r2[2] = 0
		self.r2[2] = 0.		
		self.sigma =[np.eye(self.d), spl.toeplitz(self.r1), spl.toeplitz(self.r1), 0.5*np.eye(self.d)]
		self.p = np.array([1.,1.,1.,0.1])
		self.p2 =  np.array([1.,1.,1.])
		self.p /= np.sum(self.p)
		self.p2 /= np.sum(self.p2)
		
		
			
		self.data_sigma = [ [invwishartrand(5, self.sigma[k]) for k in range(self.K)] for n in range(self.n_y)]  # @UnusedVariable
		self.data_mu    = [ [self.mu[k]+ np.random.randn(self.d)*0.2 for k in range(self.K)] for n in range(self.n_y)]  # @UnusedVariable
		
		self.Y = []
		for i in range(self.n_y):
			
			if i < 17:
				mix = mixture(K = self.K)
				mix.mu = self.data_mu[i]
				mix.sigma = self.data_sigma[i]
				mix.p = self.p
			else:
				mix = mixture(K = self.K-1)
				mix.mu = self.data_mu[i][:-1]
				mix.sigma = self.data_sigma[i][:-1]
				mix.p = self.p2
			mix.d = self.d
			self.Y.append(mix.simulate_data(self.n_obs))
		self.hGMM.set_data(self.Y)
		self.hGMM.set_prior_param0()
		self.hGMM.set_p_labelswitch(0.5)
		self.hGMM.set_p_activation([0,0])
	def setdata(self):
		
		if MPI.COMM_WORLD.Get_rank() == 0:  # @UndefinedVariable
			self.mu = [np.repeat(np.double(k),self.d) for k in range(self.K)]
			self.r1 =  np.zeros(self.d)
			self.r1[0] = 3.
			self.r1[1] = -1
			self.r1[2] = 1
			self.r1[2] = .5
			self.r2 =  np.zeros(self.d)
			self.r2[0] = 2.
			self.r2[1] = -1.5
			self.r2[2] = 0
			self.r2[2] = 0.		
			self.sigma =[np.eye(self.d), spl.toeplitz(self.r1), spl.toeplitz(self.r1), 0.5*np.eye(self.d)]
			self.p = np.array([1.,1.,1.,0.1])
			self.p2 =  np.array([1.,1.,1.])
			self.p /= np.sum(self.p)
			self.p2 /= np.sum(self.p2)
			
			
			
			self.data_sigma = [ [invwishartrand(5, self.sigma[k]) for k in range(self.K)] for n in range(self.n_y)]  # @UnusedVariable
			self.data_mu    = [ [self.mu[k]+ np.random.randn(self.d)*0.2 for k in range(self.K)] for n in range(self.n_y)]  # @UnusedVariable
			
			self.Y = []
			for i in range(self.n_y):
				
				if i < 17:
					mix = mixture(K = self.K)
					mix.mu = self.data_mu[i]
					mix.sigma = self.data_sigma[i]
					mix.p = self.p
				else:
					mix = mixture(K = self.K-1)
					mix.mu = self.data_mu[i][:-1]
					mix.sigma = self.data_sigma[i][:-1]
					mix.p = self.p2
				mix.d = self.d
				self.Y.append(mix.simulate_data(self.n_obs))
		else:
			self.Y = None		
def generate_data(n_obs, K):
    d = 4
    n_y = 20
    mu = [np.repeat(np.double(k), d) for k in range(K)]
    r1 = np.zeros(d)
    r1[0] = 3.
    r1[1] = -1
    r1[2] = 1
    r1[2] = .5
    r2 = np.zeros(d)
    r2[0] = 2.
    r2[1] = -1.5
    r2[2] = 0
    r2[2] = 0.
    sigma = [np.eye(d), spl.toeplitz(r1), spl.toeplitz(r1), 0.5 * np.eye(d)]
    p = np.array([1., 1., 1., 0.1])
    p2 = np.array([1., 1., 1.])
    p /= np.sum(p)
    p2 /= np.sum(p2)
    data_sigma = [[invwishartrand(10 + d, sigma[k]) for k in range(K)]
                  for n in range(n_y)]  # @UnusedVariable
    data_mu = [[mu[k] + np.random.randn(d) * 0.005 for k in range(K)]
               for n in range(n_y)]  # @UnusedVariable

    Y = []
    for i in range(n_y):

        if i < 17:
            mix = mixture(K=K)
            mix.mu = data_mu[i]
            mix.sigma = data_sigma[i]
            mix.p = p
        else:
            mix = mixture(K=K - 1)
            mix.mu = data_mu[i][:-1]
            mix.sigma = data_sigma[i][:-1]
            mix.p = p2
        mix.d = d
        Y.append(mix.simulate_data(n_obs))

    return Y, data_sigma, data_mu
def generate_data( n_obs, K):
	d = 4
	n_y = 20
	mu = [np.repeat(np.double(k),d) for k in range(K)]
	r1 =  np.zeros(d)
	r1[0] = 3.
	r1[1] = -1
	r1[2] = 1
	r1[2] = .5
	r2 =  np.zeros(d)
	r2[0] = 2.
	r2[1] = -1.5
	r2[2] = 0
	r2[2] = 0.		
	sigma =[np.eye(d), spl.toeplitz(r1), spl.toeplitz(r1), 0.5*np.eye(d)]
	p = np.array([1.,1.,1.,0.1])
	p2 =  np.array([1.,1.,1.])
	p /= np.sum(p)
	p2 /= np.sum(p2)
	data_sigma = [ [invwishartrand(10+d, sigma[k]) for k in range(K)] for n in range(n_y)]  # @UnusedVariable
	data_mu    = [ [mu[k]+ np.random.randn(d)*0.005 for k in range(K)] for n in range(n_y)]  # @UnusedVariable
		
	Y = []
	for i in range(n_y):
		
		if i < 17:
			mix = mixture(K = K)
			mix.mu = data_mu[i]
			mix.sigma = data_sigma[i]
			mix.p = p
		else:
			mix = mixture(K = K-1)
			mix.mu = data_mu[i][:-1]
			mix.sigma = data_sigma[i][:-1]
			mix.p = p2
		mix.d = d
		Y.append(mix.simulate_data(n_obs))
	
	return Y, data_sigma, data_mu
Beispiel #6
0
	def generate_data(self, p ):
		
		self.mu = [np.repeat(np.double(k),self.d) for k in range(self.K)]
		self.sigma =[np.eye(self.d)*0.01 for k in range (self.K)]
		mix = mixture(K = self.K)
		mix.mu = self.mu
		mix.sigma = self.sigma
		mix.p = p
		mix.d = self.d
		self.Y = mix.simulate_data(self.n_obs)
		self.mix.mu = self.mu
		self.mix.sigma = self.sigma
		self.mix.p = p
		self.mix.d = self.d
		self.mix.set_data(self.Y)
	def generate_data_mu(self ):
		p = np.ones(self.K)/self.K
		self.mu = [np.repeat(np.double(k),self.d) for k in range(self.K)]
		self.sigma =[np.eye(self.d)*0.01 for k in range (self.K)]
		mix = mixture(K = self.K)
		mix.mu = self.mu
		mix.sigma = self.sigma
		mix.p = p
		mix.d = self.d
		self.Y = mix.simulate_data(self.n_obs)
		self.mix.mu = cp.deepcopy(self.mu)
		self.mix.sigma = cp.deepcopy(self.sigma)
		self.mix.p =cp.deepcopy( p)
		self.mix.d = self.d
		self.mix.set_data(self.Y)
 def generate_data_mu(self):
     p = np.ones(self.K) / self.K
     self.mu = [np.repeat(np.double(k), self.d) for k in range(self.K)]
     self.sigma = [np.eye(self.d) * 0.01 for k in range(self.K)]
     mix = mixture(K=self.K)
     mix.mu = self.mu
     mix.sigma = self.sigma
     mix.p = p
     mix.d = self.d
     self.Y = mix.simulate_data(self.n_obs)
     self.mix.mu = cp.deepcopy(self.mu)
     self.mix.sigma = cp.deepcopy(self.sigma)
     self.mix.p = cp.deepcopy(p)
     self.mix.d = self.d
     self.mix.set_data(self.Y)
    def generate_data(self, p):

        self.mu = [np.repeat(np.double(k), self.d) for k in range(self.K)]
        self.sigma = [np.eye(self.d) * 0.01 for k in range(self.K)]
        mix = mixture(K=self.K)
        mix.mu = self.mu
        mix.sigma = self.sigma
        mix.p = p
        mix.d = self.d
        self.Y = mix.simulate_data(self.n_obs)
        self.mix.mu = self.mu
        self.mix.sigma = self.sigma
        self.mix.p = p
        self.mix.d = self.d
        self.mix.set_data(self.Y)
	def generate_data_sigma(self ):
		p = np.ones(self.K)/self.K
		self.mu = [np.repeat(np.double(k),self.d) for k in range(self.K-1)]
		self.mu.append(np.repeat(np.double(0),self.d) )
		self.sigma =[spl.toeplitz(self.r)*0.01 for k in range (self.K-1)]
		self.sigma.append(np.eye(self.d)*0.01 )
		mix = mixture(K = self.K)
		mix.mu = self.mu
		mix.sigma = self.sigma
		mix.p = p
		mix.d = self.d
		self.Y = mix.simulate_data(self.n_obs)
		self.mix.mu = cp.deepcopy(self.mu)
		self.mix.sigma = cp.deepcopy(self.sigma)
		self.mix.p =cp.deepcopy( p)
		self.mix.d = self.d
		self.mix.set_data(self.Y)
 def generate_data_sigma(self):
     p = np.ones(self.K) / self.K
     self.mu = [np.repeat(np.double(k), self.d) for k in range(self.K - 1)]
     self.mu.append(np.repeat(np.double(0), self.d))
     self.sigma = [spl.toeplitz(self.r) * 0.01 for k in range(self.K - 1)]
     self.sigma.append(np.eye(self.d) * 0.01)
     mix = mixture(K=self.K)
     mix.mu = self.mu
     mix.sigma = self.sigma
     mix.p = p
     mix.d = self.d
     self.Y = mix.simulate_data(self.n_obs)
     self.mix.mu = cp.deepcopy(self.mu)
     self.mix.sigma = cp.deepcopy(self.sigma)
     self.mix.p = cp.deepcopy(p)
     self.mix.d = self.d
     self.mix.set_data(self.Y)
Beispiel #12
0
	def test_generate_data(self):
		
		if self.comm.Get_rank() == 0:
			self.mu = [np.repeat(np.double(k),self.d) for k in range(self.K)]
			r = np.zeros(self.d)
			r[0] = 3.
			r[1] = -1
			self.sigma = [spl.toeplitz(r) for k in range(self.K)]
			
			self.data_sigma = [ [invwishartrand(5, self.sigma[k]) for k in range(self.K)] for n in range(self.n)]  # @UnusedVariable
			self.data_mu    = [ [self.mu[k]+ np.random.randn(self.d)*0.2 for k in range(self.K)] for n in range(self.n)]  # @UnusedVariable
			self.Y = []
			for i in range(self.n):
				mix = mixture(K = self.K)
				mix.mu = self.data_mu[i]
				mix.sigma = self.data_sigma[i]
				mix.p = np.ones(self.K) / self.K
				mix.d = self.d
				self.Y.append(mix.simulate_data(self.n_obs))
		else:
			self.Y = None
		self.hGMM.set_data(self.Y)
		self.hGMM.set_prior_param0()