Skip to content

Commit 009e4b0

Browse files
committed
Fix: axes created and dropped
1 parent cae4cb8 commit 009e4b0

File tree

1 file changed

+76
-0
lines changed

1 file changed

+76
-0
lines changed

kaleidoscope/interface/random.py

Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
# Copyright (c) Brockmann Consult GmbH, 2025
2+
# License: MIT
3+
4+
"""
5+
This module provides interfaces for generating random numbers.
6+
"""
7+
8+
from abc import ABC
9+
from abc import abstractmethod
10+
11+
import numpy as np
12+
13+
14+
class Generating(ABC):
15+
"""Random number generating interface."""
16+
17+
@abstractmethod
18+
def random(self) -> int:
19+
"""
20+
Returns a new integer random number.
21+
22+
Generated random numbers are uniformly distributed in the
23+
interval [0, 18446744073709551615].
24+
25+
:return: The new integer random number.
26+
"""
27+
28+
29+
class Univariate(ABC):
30+
"""Univariate random variates."""
31+
32+
@abstractmethod
33+
def random(self) -> float:
34+
"""
35+
Returns a new random number.
36+
37+
:return: The new random number.
38+
"""
39+
40+
@abstractmethod
41+
def randoms(self, randoms: np.ndarray) -> np.ndarray:
42+
"""
43+
Returns a sequence of newly generated random numbers.
44+
45+
:param randoms: To store the sequence.
46+
:return: The sequence of newly generated random numbers.
47+
"""
48+
49+
50+
class Multivariate(ABC):
51+
"""Multivariate random variates."""
52+
53+
@abstractmethod
54+
def get(self, i: int) -> Univariate:
55+
"""
56+
Returns a univariate random variate for a given dimension.
57+
58+
:param i: The dimension.
59+
:return: The univariate random variate for the given dimension.
60+
"""
61+
62+
63+
class Normal(Univariate, Multivariate, ABC):
64+
"""
65+
Normal random variates.
66+
67+
Generated random numbers are standard normally distributed.
68+
"""
69+
70+
71+
class Uniform(Univariate, Multivariate, ABC):
72+
"""
73+
Uniform random variates.
74+
75+
Generated random numbers are uniformly distributed in [0, 1).
76+
"""

0 commit comments

Comments
 (0)