Simulate data according to an instantaneous mixin model. Data are simulated in the statistical source space, where one source is modulated according to a target variable, before being mixed with a random mixing matrix.
(target, n_trials=100, n_channels=10, random_state=42)
| 36 | |
| 37 | |
| 38 | def simulate_data(target, n_trials=100, n_channels=10, random_state=42): |
| 39 | """Simulate data according to an instantaneous mixin model. |
| 40 | |
| 41 | Data are simulated in the statistical source space, where one source is |
| 42 | modulated according to a target variable, before being mixed with a |
| 43 | random mixing matrix. |
| 44 | """ |
| 45 | rs = np.random.RandomState(random_state) |
| 46 | |
| 47 | # generate a orthogonal mixin matrix |
| 48 | mixing_mat = np.linalg.svd(rs.randn(n_channels, n_channels))[0] |
| 49 | |
| 50 | S = rs.randn(n_trials, n_channels, 50) |
| 51 | S[:, 0] *= np.atleast_2d(np.sqrt(target)).T |
| 52 | S[:, 1:] *= 0.01 # less noise |
| 53 | |
| 54 | X = np.dot(mixing_mat, S).transpose((1, 0, 2)) |
| 55 | |
| 56 | return X, mixing_mat |
| 57 | |
| 58 | |
| 59 | def deterministic_toy_data(classes=("class_a", "class_b")): |