master > master: src - clean up
- enums für Alphabete - button layout - refresh Knopf - aspect ratio
This commit is contained in:
24
src/thirdparty/maths.py
vendored
24
src/thirdparty/maths.py
vendored
@@ -9,6 +9,29 @@ from fractions import Fraction;
|
||||
import math;
|
||||
import numpy as np;
|
||||
import random;
|
||||
from typing import TypeVar;
|
||||
|
||||
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
# MODIFICATIONS
|
||||
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
# local usage only
|
||||
T = TypeVar('T');
|
||||
|
||||
def sample(
|
||||
X: list[T],
|
||||
size: int = 1,
|
||||
replace: bool = True,
|
||||
) -> list[T]:
|
||||
'''
|
||||
@inputs
|
||||
- `X` - a list
|
||||
- `size` <int> - desired sample size
|
||||
- `replace` <bool> - optional replacement
|
||||
|
||||
@returns a sample from an uniformly distributed set.
|
||||
'''
|
||||
return np.random.choice(X, size=size, replace=replace).tolist();
|
||||
|
||||
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
# EXPORTS
|
||||
@@ -19,4 +42,5 @@ __all__ = [
|
||||
'math',
|
||||
'np',
|
||||
'random',
|
||||
'sample',
|
||||
];
|
||||
|
||||
Reference in New Issue
Block a user