Пример #1
0
def test_fit_stabilize_1D():
	n = 1000
	mu = [-6, 5, 13] #+ [-20, 40, 80]
	sigma = [2, 3, 2.5] #+ [1, 1.8, 5]
	X = []
	for i in range(n):
	    Z = np.random.choice(np.arange(len(mu))) # select the synthetic component
	    X.append(np.random.normal(mu[Z], sigma[Z], 1))
	X = np.array(X)
	sgmm = SGMM()
	sgmm.fit(X)
	assert len(sgmm.cores) == 3
Пример #2
0
def test_fit_stabilize_2D():
	n = 200
	mu = [[10.4, 10.2], [-1.4, 1.6], [2.4, 5.4], [6.4, 2.4]]
	sigma = []
	for s in range(len(mu)):
	  sigma.append(make_spd_matrix(2))
	X = []
	for m, s in zip(mu,sigma):
	  x = np.random.multivariate_normal(m, s, n)
	  X += list(x)
	X = np.array(X)
	np.random.shuffle(X)
	sgmm = SGMM()
	sgmm.fit(X)
	assert len(sgmm.cores) == 4
Пример #3
0
def test_fit_no_stabilize():
	sgmm = SGMM(stabilize=None)
	sgmm.fit([0,1,5,2,35,4,5,7,5,3,5,3,2])
	assert len(sgmm.cores) == 5