my fix for simulation
@@ -157,21 +157,21 @@ def make_signal(G, n_channel,make_exact=False, chol_channel=None):
# We use two-step procedure allow for different distributions later on
true_U = np.random.uniform(0, 1, size=(n_cond, n_channel))
true_U = ss.norm.ppf(true_U)
+ true_U = true_U - np.mean(true_U, axis=1, keepdims=True)
# Make orthonormal row vectors
if (make_exact):
E = true_U @ true_U.transpose()
- L = np.linalg.cholesky(E)
- true_U = np.linalg.solve(L, true_U) * np.sqrt(n_channel)
+ E_chol = np.linalg.cholesky(E)
+ true_U = np.linalg.solve(E_chol, true_U) * np.sqrt(n_channel)
# Impose spatial covariance matrix
if (chol_channel is not None):
true_U = true_U @ chol_channel
# Now produce data with the known second-moment matrix
# Use positive eigenvectors only
# (cholesky does not work with rank-deficient matrices)
- lam, V = np.linalg.eigh(G)
- lam[lam < 1e-15] = 0
- lam = np.sqrt(lam)
- chol_G = V * lam.reshape((1, V.shape[1]))
+ L, D, perm = sl.ldl(G)
+ D[D < 1e-15] = 0
+ D = np.sqrt(D)
+ chol_G = L @ D
true_U = (chol_G @ true_U)
- print('d')
return true_U
\ No newline at end of file
