A = np.random.rand(sig.shape[0] + 1, sig.shape[0]) x = A @ sig # x += 0.1*np.random.randn(*x.shape) xm = x - x.mean(axis=1)[:, None] # #### Perform PCA u, s, v = np.linalg.svd(xm, full_matrices=False) nm = np.sum(s > 1e-6) s_pca = v[:nm, :].T * s[:nm] # #### Apply ICA xw = (u / s).T[:sig.shape[0]] @ xm xw *= np.sqrt(xm.shape[1]) ica = FastICA(algorithm='deflation', tol=1e-12) ica.whiten = True ica.n_components = sig.shape[0] s_ica = ica.fit_transform(xm.T) # ica.whiten = False # s_ica = ica.fit_transform(xw.T) s_ica *= s[:nm].mean() # #### Plot data f = mplt.figure(figsize=(10, 10)) gs = mgs.GridSpec(4, 3) gs.update(top=0.96, bottom=0.05, left=0.08, right=0.98, hspace=0.3, wspace=0.35)