| from __future__ import annotations | |
| import numpy as np | |
| def generate_sources(samples: int, seed: int) -> tuple[np.ndarray, np.ndarray]: | |
| rng = np.random.default_rng(seed) | |
| source1 = rng.laplace(size=samples) / np.sqrt(2) | |
| source2 = rng.uniform(-np.sqrt(3), np.sqrt(3), size=samples) | |
| sources = np.column_stack([source1, source2]).astype(np.float32) | |
| mixing = np.asarray([[1.0, 0.85], [0.55, 1.25]], dtype=np.float32) | |
| observations = sources @ mixing.T | |
| return sources, observations.astype(np.float32) | |