File size: 523 Bytes
57e11c5
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
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)