gregs-rng 0.1.4__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- gregs_rng-0.1.4/.github/workflows/pypi.yml +56 -0
- gregs_rng-0.1.4/LICENSE +21 -0
- gregs_rng-0.1.4/PKG-INFO +52 -0
- gregs_rng-0.1.4/README.md +37 -0
- gregs_rng-0.1.4/pyproject.toml +43 -0
- gregs_rng-0.1.4/setup.cfg +4 -0
- gregs_rng-0.1.4/src/gregs_rng/__init__.py +11 -0
- gregs_rng-0.1.4/src/gregs_rng/rng.py +29 -0
- gregs_rng-0.1.4/src/gregs_rng.egg-info/PKG-INFO +52 -0
- gregs_rng-0.1.4/src/gregs_rng.egg-info/SOURCES.txt +10 -0
- gregs_rng-0.1.4/src/gregs_rng.egg-info/dependency_links.txt +1 -0
- gregs_rng-0.1.4/src/gregs_rng.egg-info/top_level.txt +1 -0
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
# https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-python#publishing-to-package-registries
|
|
2
|
+
|
|
3
|
+
name: Publish to PyPI
|
|
4
|
+
|
|
5
|
+
on:
|
|
6
|
+
workflow_dispatch:
|
|
7
|
+
push:
|
|
8
|
+
tags:
|
|
9
|
+
- "v*"
|
|
10
|
+
|
|
11
|
+
permissions:
|
|
12
|
+
contents: read
|
|
13
|
+
|
|
14
|
+
jobs:
|
|
15
|
+
release-build:
|
|
16
|
+
runs-on: ubuntu-latest
|
|
17
|
+
|
|
18
|
+
steps:
|
|
19
|
+
- uses: actions/checkout@v4
|
|
20
|
+
|
|
21
|
+
- uses: actions/setup-python@v5
|
|
22
|
+
with:
|
|
23
|
+
python-version: "3.10.12"
|
|
24
|
+
|
|
25
|
+
- name: Build release distributions
|
|
26
|
+
run: |
|
|
27
|
+
python -m pip install build setuptools-scm
|
|
28
|
+
python -m build
|
|
29
|
+
|
|
30
|
+
- name: Upload distributions
|
|
31
|
+
uses: actions/upload-artifact@v4
|
|
32
|
+
with:
|
|
33
|
+
name: release-dists
|
|
34
|
+
path: dist/
|
|
35
|
+
|
|
36
|
+
pypi-publish:
|
|
37
|
+
runs-on: ubuntu-latest
|
|
38
|
+
needs:
|
|
39
|
+
- release-build
|
|
40
|
+
permissions:
|
|
41
|
+
id-token: write
|
|
42
|
+
|
|
43
|
+
environment:
|
|
44
|
+
name: testpypi
|
|
45
|
+
|
|
46
|
+
steps:
|
|
47
|
+
- name: Retrieve release distributions
|
|
48
|
+
uses: actions/download-artifact@v4
|
|
49
|
+
with:
|
|
50
|
+
name: release-dists
|
|
51
|
+
path: dist/
|
|
52
|
+
|
|
53
|
+
- name: Publish release distributions to PyPI
|
|
54
|
+
uses: pypa/gh-action-pypi-publish@release/v1
|
|
55
|
+
with:
|
|
56
|
+
packages-dir: dist/
|
gregs_rng-0.1.4/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) [year] [fullname]
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
gregs_rng-0.1.4/PKG-INFO
ADDED
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: gregs_rng
|
|
3
|
+
Version: 0.1.4
|
|
4
|
+
Summary: Contains implementations of Random Number Generators
|
|
5
|
+
Author: Greg Dorshimer
|
|
6
|
+
Project-URL: Homepage, https://github.com/gregdorshimer/gregs_rng
|
|
7
|
+
Project-URL: Issues, https://github.com/gregdorshimer/gregs_rng/issues
|
|
8
|
+
Keywords: random,rng,statistics,linear congruential generator
|
|
9
|
+
Classifier: Programming Language :: Python :: 3
|
|
10
|
+
Classifier: Operating System :: OS Independent
|
|
11
|
+
Requires-Python: >=3.10.12
|
|
12
|
+
Description-Content-Type: text/markdown
|
|
13
|
+
License-File: LICENSE
|
|
14
|
+
Dynamic: license-file
|
|
15
|
+
|
|
16
|
+
# gregs_rng
|
|
17
|
+
|
|
18
|
+
A package for generating random numbers using various methods. The current version only supports the Linear Congruential Method.
|
|
19
|
+
|
|
20
|
+
Linear Congruential Generator:
|
|
21
|
+
|
|
22
|
+
Thompson, W. E. (1958). A Modified Congruence Method of Generating Pseudo-Random Numbers. The Computer Journal, 1(2), 83–88.
|
|
23
|
+
https://academic.oup.com/comjnl/article-abstract/1/2/83/425243
|
|
24
|
+
Rotenberg, A. (1960). A New Pseudo-Random Number Generator. Journal of the ACM, 7(1), 75–77.
|
|
25
|
+
https://dl.acm.org/doi/10.1145/321008.321019
|
|
26
|
+
https://en.wikipedia.org/wiki/Linear_congruential_generator
|
|
27
|
+
|
|
28
|
+
|
|
29
|
+
Choice of parameters for LCG:
|
|
30
|
+
|
|
31
|
+
Donald E. Knuth (1981). The Art of Computer Programming, Volume 2: Seminumerical Algorithms (2nd ed.). Addison-Wesley.
|
|
32
|
+
https://en.wikipedia.org/wiki/The_Art_of_Computer_Programming
|
|
33
|
+
|
|
34
|
+
Press, W. H., Teukolsky, S. A., Vetterling, W. T., & Flannery, B. P. Numerical Recipes in C: The Art of Scientific Computing, 2nd ed., Cambridge University Press, 1992.
|
|
35
|
+
https://en.wikipedia.org/wiki/Numerical_Recipes
|
|
36
|
+
|
|
37
|
+
|
|
38
|
+
Install:
|
|
39
|
+
|
|
40
|
+
```bash
|
|
41
|
+
pip install gregs_rng
|
|
42
|
+
```
|
|
43
|
+
|
|
44
|
+
Import and Use:
|
|
45
|
+
|
|
46
|
+
```python
|
|
47
|
+
from gregs_rng import lcg
|
|
48
|
+
|
|
49
|
+
g = lcg(42)
|
|
50
|
+
print(next(g))
|
|
51
|
+
print(next(g))
|
|
52
|
+
```
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
# gregs_rng
|
|
2
|
+
|
|
3
|
+
A package for generating random numbers using various methods. The current version only supports the Linear Congruential Method.
|
|
4
|
+
|
|
5
|
+
Linear Congruential Generator:
|
|
6
|
+
|
|
7
|
+
Thompson, W. E. (1958). A Modified Congruence Method of Generating Pseudo-Random Numbers. The Computer Journal, 1(2), 83–88.
|
|
8
|
+
https://academic.oup.com/comjnl/article-abstract/1/2/83/425243
|
|
9
|
+
Rotenberg, A. (1960). A New Pseudo-Random Number Generator. Journal of the ACM, 7(1), 75–77.
|
|
10
|
+
https://dl.acm.org/doi/10.1145/321008.321019
|
|
11
|
+
https://en.wikipedia.org/wiki/Linear_congruential_generator
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
Choice of parameters for LCG:
|
|
15
|
+
|
|
16
|
+
Donald E. Knuth (1981). The Art of Computer Programming, Volume 2: Seminumerical Algorithms (2nd ed.). Addison-Wesley.
|
|
17
|
+
https://en.wikipedia.org/wiki/The_Art_of_Computer_Programming
|
|
18
|
+
|
|
19
|
+
Press, W. H., Teukolsky, S. A., Vetterling, W. T., & Flannery, B. P. Numerical Recipes in C: The Art of Scientific Computing, 2nd ed., Cambridge University Press, 1992.
|
|
20
|
+
https://en.wikipedia.org/wiki/Numerical_Recipes
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
Install:
|
|
24
|
+
|
|
25
|
+
```bash
|
|
26
|
+
pip install gregs_rng
|
|
27
|
+
```
|
|
28
|
+
|
|
29
|
+
Import and Use:
|
|
30
|
+
|
|
31
|
+
```python
|
|
32
|
+
from gregs_rng import lcg
|
|
33
|
+
|
|
34
|
+
g = lcg(42)
|
|
35
|
+
print(next(g))
|
|
36
|
+
print(next(g))
|
|
37
|
+
```
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
[build-system]
|
|
2
|
+
requires = ["setuptools>=64.0", "setuptools-scm"]
|
|
3
|
+
build-backend = "setuptools.build_meta"
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
[project]
|
|
7
|
+
# Name used to install with pip:
|
|
8
|
+
name = "gregs_rng"
|
|
9
|
+
|
|
10
|
+
# Current version of this package pulled from git tag by setuptools-scm:
|
|
11
|
+
dynamic = ["version"]
|
|
12
|
+
|
|
13
|
+
# Description published on PyPI:
|
|
14
|
+
description = "Contains implementations of Random Number Generators"
|
|
15
|
+
|
|
16
|
+
readme = "README.md"
|
|
17
|
+
|
|
18
|
+
requires-python = ">=3.10.12"
|
|
19
|
+
|
|
20
|
+
authors = [
|
|
21
|
+
{name = "Greg Dorshimer"}
|
|
22
|
+
]
|
|
23
|
+
|
|
24
|
+
# Keywords for help finding the package:
|
|
25
|
+
keywords = ["random", "rng", "statistics", "linear congruential generator"]
|
|
26
|
+
|
|
27
|
+
# PyPI Classifiers describing the package:
|
|
28
|
+
classifiers = [
|
|
29
|
+
"Programming Language :: Python :: 3",
|
|
30
|
+
"Operating System :: OS Independent"
|
|
31
|
+
]
|
|
32
|
+
|
|
33
|
+
[project.urls]
|
|
34
|
+
Homepage = "https://github.com/gregdorshimer/gregs_rng"
|
|
35
|
+
Issues = "https://github.com/gregdorshimer/gregs_rng/issues"
|
|
36
|
+
|
|
37
|
+
|
|
38
|
+
[tool.setuptools.packages.find]
|
|
39
|
+
# define /src/ as the root of importable packages
|
|
40
|
+
where = ["src"]
|
|
41
|
+
|
|
42
|
+
|
|
43
|
+
[tool.setuptools_scm]
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
from collections.abc import Generator
|
|
2
|
+
|
|
3
|
+
# lcg is a Generator that yields `int`, receives `None` from .send(), and returns `None` when it finishes
|
|
4
|
+
# `seed` is required
|
|
5
|
+
# `lcg` returns uniform random variates [0,1]
|
|
6
|
+
def lcg(seed: int, a: int = 1664525, c: int = 1013904223, m: int = 2**32) -> Generator[float, None, None]:
|
|
7
|
+
# enforce non-negative `seed`
|
|
8
|
+
if not isinstance(seed, int) or seed < 0:
|
|
9
|
+
raise ValueError('Bad inputs to `lcg`: `seed` must be non-negative.')
|
|
10
|
+
|
|
11
|
+
# enforce positive `a`,
|
|
12
|
+
if not isinstance(a, int) or a < 1:
|
|
13
|
+
raise ValueError('Bad inputs to `lcg`: `a` must be positive.')
|
|
14
|
+
|
|
15
|
+
# enforce non-negative `c`,
|
|
16
|
+
if not isinstance(c, int) or c < 0:
|
|
17
|
+
raise ValueError('Bad inputs to `lcg`: `c` must be non-negative.')
|
|
18
|
+
|
|
19
|
+
# enforce `m` greater than 1,
|
|
20
|
+
if not isinstance(m, int) or m < 2:
|
|
21
|
+
raise ValueError('Bad inputs to `lcg`: `m` must be greater than 1.')
|
|
22
|
+
|
|
23
|
+
while True:
|
|
24
|
+
seed = (a * seed + c) % m
|
|
25
|
+
yield seed / m
|
|
26
|
+
|
|
27
|
+
g = lcg(seed = 144386231)
|
|
28
|
+
for i in range(50):
|
|
29
|
+
print(next(g))
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: gregs_rng
|
|
3
|
+
Version: 0.1.4
|
|
4
|
+
Summary: Contains implementations of Random Number Generators
|
|
5
|
+
Author: Greg Dorshimer
|
|
6
|
+
Project-URL: Homepage, https://github.com/gregdorshimer/gregs_rng
|
|
7
|
+
Project-URL: Issues, https://github.com/gregdorshimer/gregs_rng/issues
|
|
8
|
+
Keywords: random,rng,statistics,linear congruential generator
|
|
9
|
+
Classifier: Programming Language :: Python :: 3
|
|
10
|
+
Classifier: Operating System :: OS Independent
|
|
11
|
+
Requires-Python: >=3.10.12
|
|
12
|
+
Description-Content-Type: text/markdown
|
|
13
|
+
License-File: LICENSE
|
|
14
|
+
Dynamic: license-file
|
|
15
|
+
|
|
16
|
+
# gregs_rng
|
|
17
|
+
|
|
18
|
+
A package for generating random numbers using various methods. The current version only supports the Linear Congruential Method.
|
|
19
|
+
|
|
20
|
+
Linear Congruential Generator:
|
|
21
|
+
|
|
22
|
+
Thompson, W. E. (1958). A Modified Congruence Method of Generating Pseudo-Random Numbers. The Computer Journal, 1(2), 83–88.
|
|
23
|
+
https://academic.oup.com/comjnl/article-abstract/1/2/83/425243
|
|
24
|
+
Rotenberg, A. (1960). A New Pseudo-Random Number Generator. Journal of the ACM, 7(1), 75–77.
|
|
25
|
+
https://dl.acm.org/doi/10.1145/321008.321019
|
|
26
|
+
https://en.wikipedia.org/wiki/Linear_congruential_generator
|
|
27
|
+
|
|
28
|
+
|
|
29
|
+
Choice of parameters for LCG:
|
|
30
|
+
|
|
31
|
+
Donald E. Knuth (1981). The Art of Computer Programming, Volume 2: Seminumerical Algorithms (2nd ed.). Addison-Wesley.
|
|
32
|
+
https://en.wikipedia.org/wiki/The_Art_of_Computer_Programming
|
|
33
|
+
|
|
34
|
+
Press, W. H., Teukolsky, S. A., Vetterling, W. T., & Flannery, B. P. Numerical Recipes in C: The Art of Scientific Computing, 2nd ed., Cambridge University Press, 1992.
|
|
35
|
+
https://en.wikipedia.org/wiki/Numerical_Recipes
|
|
36
|
+
|
|
37
|
+
|
|
38
|
+
Install:
|
|
39
|
+
|
|
40
|
+
```bash
|
|
41
|
+
pip install gregs_rng
|
|
42
|
+
```
|
|
43
|
+
|
|
44
|
+
Import and Use:
|
|
45
|
+
|
|
46
|
+
```python
|
|
47
|
+
from gregs_rng import lcg
|
|
48
|
+
|
|
49
|
+
g = lcg(42)
|
|
50
|
+
print(next(g))
|
|
51
|
+
print(next(g))
|
|
52
|
+
```
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
LICENSE
|
|
2
|
+
README.md
|
|
3
|
+
pyproject.toml
|
|
4
|
+
.github/workflows/pypi.yml
|
|
5
|
+
src/gregs_rng/__init__.py
|
|
6
|
+
src/gregs_rng/rng.py
|
|
7
|
+
src/gregs_rng.egg-info/PKG-INFO
|
|
8
|
+
src/gregs_rng.egg-info/SOURCES.txt
|
|
9
|
+
src/gregs_rng.egg-info/dependency_links.txt
|
|
10
|
+
src/gregs_rng.egg-info/top_level.txt
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
gregs_rng
|