Initial commit

This commit is contained in:
2025-12-16 14:52:36 +01:00
commit b6e94e75ac
11 changed files with 269 additions and 0 deletions
+16
View File
@@ -0,0 +1,16 @@
import numpy as np
import time
rng = np.random.default_rng(int(time.monotonic()))
def uniform(shape: tuple, mu: float = 0.5, std: float = 1.0) -> np.ndarray:
return std * (rng.uniform(size=shape) + mu - 0.5)
def gaussian(shape: tuple, mu: float = 0.5, std: float = 1.0) -> np.ndarray:
return rng.normal(size=shape, loc=mu, scale=std)
def sample(src: np.ndarray) -> np.ndarray:
return (src > uniform(src.shape)).astype(float)
def prob(src: np.ndarray) -> np.ndarray:
return 1.0 / (1 + np.exp(-src))