Beispiel #1
0
p = 2

N = 10**5

s1 = np.sin((np.arange(N)+1)/200)
s2 = np.mod((np.arange(N)+1)/200, 2) - 1
S = np.concatenate([s.reshape((1,N)) for s in [s1, s2]], 0)
S = S - np.mean(S,1).reshape((p,1))

A = np.array([[1,2],[-2,1]])

X = A.dot(S)

#D = sp.linalg.sqrtm(np.linalg.inv(X.dot(X.T)/N))

icasig, W, B, b = ica_reg(X, np.zeros((2, 1)), alpha=0.0001, lamda=0.0)

print(W, B, b)

plt.subplot(4,1,1)
plt.plot(X[0, :10000])
plt.subplot(4,1,2)
plt.plot(X[1, :10000])
plt.subplot(4,1,3)
plt.plot(icasig[0, :10000])
plt.subplot(4,1,4)
plt.plot(icasig[1, :10000])
plt.savefig('test.pdf')


Beispiel #2
0
fastica = FastICA()
S_fastica = fastica.fit_transform(X.T).T*np.sqrt(n)
A_fastica = fastica.mixing_/np.sqrt(n)
lr = LinearRegression()
B_fastica = lr.fit(A_fastica, Y_true).coef_.T

plt.figure()
plt.imshow(np.abs(B_fastica), interpolation="none", cmap='viridis')
#plt.clim(-2, 2)
plt.colorbar()
plt.savefig('exp_000a.pdf')

plt.figure()
plt.imshow(np.abs(S_fastica.dot(S.T)/n), interpolation="none", cmap='viridis', vmin=0, vmax=0.4)
plt.colorbar()
plt.savefig('exp_000aS.pdf')

S_hat, W_hat, B_hat = ica_reg(X, Y_true, alpha=1e-3, lamda=1e0, ica_obj=tf_ica_supergaussian_obj)

plt.figure()
plt.imshow(np.abs(B_hat), interpolation="none", cmap='viridis')
#plt.clim(-2, 2)
plt.colorbar()
plt.savefig('exp_000b.pdf')

plt.figure()
plt.imshow(np.abs(S_hat.dot(S.T)/n), interpolation="none", cmap='viridis', vmin=0, vmax=0.4)
plt.colorbar()
plt.savefig('exp_000bS.pdf')