Esempio n. 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
Esempio n. 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
Esempio n. 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
Esempio n. 4
0
def test_fit_stabilize(data, init_cores):
	sgmm = SGMM(init_cores=init_cores)
	sgmm._fit_stabilize(data)
Esempio n. 5
0
def test_truncate_interval(data, interval, abic):
	sgmm = SGMM()
	sgmm._truncate_interval(data, interval, abic)
Esempio n. 6
0
def test_halve_interval(data, interval, abic, midpoint, abic_m):
	sgmm = SGMM()
	sgmm._halve_interval(data, interval, abic, midpoint, abic_m)
Esempio n. 7
0
def test_orient_stabilizer(data, init_cores):
	sgmm = SGMM(init_cores=init_cores)
	sgmm._orient_stabilizer(data)