stochpylib 0.1.0__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.
Files changed (30) hide show
  1. stochpylib-0.1.0/LICENSE +21 -0
  2. stochpylib-0.1.0/PKG-INFO +285 -0
  3. stochpylib-0.1.0/README.md +262 -0
  4. stochpylib-0.1.0/pyproject.toml +40 -0
  5. stochpylib-0.1.0/setup.cfg +4 -0
  6. stochpylib-0.1.0/stochpylib/__init__.py +5 -0
  7. stochpylib-0.1.0/stochpylib/cli.py +138 -0
  8. stochpylib-0.1.0/stochpylib/distributions/__init__.py +122 -0
  9. stochpylib-0.1.0/stochpylib/distributions/_base.py +268 -0
  10. stochpylib-0.1.0/stochpylib/distributions/continuous.py +1185 -0
  11. stochpylib-0.1.0/stochpylib/distributions/discrete.py +559 -0
  12. stochpylib-0.1.0/stochpylib/distributions/heavy_tail.py +293 -0
  13. stochpylib-0.1.0/stochpylib/distributions/multivariate.py +287 -0
  14. stochpylib-0.1.0/stochpylib/montecarlo/__init__.py +81 -0
  15. stochpylib-0.1.0/stochpylib/montecarlo/_result.py +51 -0
  16. stochpylib-0.1.0/stochpylib/montecarlo/applications.py +156 -0
  17. stochpylib-0.1.0/stochpylib/montecarlo/quasi_random.py +388 -0
  18. stochpylib-0.1.0/stochpylib/montecarlo/simulation.py +199 -0
  19. stochpylib-0.1.0/stochpylib/montecarlo/variance_reduction.py +231 -0
  20. stochpylib-0.1.0/stochpylib/probability/__init__.py +51 -0
  21. stochpylib-0.1.0/stochpylib/probability/basics.py +130 -0
  22. stochpylib-0.1.0/stochpylib/probability/combinatorics.py +120 -0
  23. stochpylib-0.1.0/stochpylib/probability/independence.py +60 -0
  24. stochpylib-0.1.0/stochpylib/selftest.py +195 -0
  25. stochpylib-0.1.0/stochpylib.egg-info/PKG-INFO +285 -0
  26. stochpylib-0.1.0/stochpylib.egg-info/SOURCES.txt +28 -0
  27. stochpylib-0.1.0/stochpylib.egg-info/dependency_links.txt +1 -0
  28. stochpylib-0.1.0/stochpylib.egg-info/entry_points.txt +2 -0
  29. stochpylib-0.1.0/stochpylib.egg-info/requires.txt +5 -0
  30. stochpylib-0.1.0/stochpylib.egg-info/top_level.txt +1 -0
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Leon Schwarzkopf
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.
@@ -0,0 +1,285 @@
1
+ Metadata-Version: 2.4
2
+ Name: stochpylib
3
+ Version: 0.1.0
4
+ Summary: A Python library for probability, distributions, stochastic processes, and statistical computing
5
+ Author: Leon Schwarzkopf
6
+ License-Expression: MIT
7
+ Classifier: Development Status :: 2 - Pre-Alpha
8
+ Classifier: Intended Audience :: Science/Research
9
+ Classifier: Programming Language :: Python :: 3
10
+ Classifier: Programming Language :: Python :: 3.10
11
+ Classifier: Programming Language :: Python :: 3.11
12
+ Classifier: Programming Language :: Python :: 3.12
13
+ Classifier: Programming Language :: Python :: 3.13
14
+ Classifier: Topic :: Scientific/Engineering :: Mathematics
15
+ Requires-Python: >=3.10
16
+ Description-Content-Type: text/markdown
17
+ License-File: LICENSE
18
+ Requires-Dist: numpy
19
+ Requires-Dist: scipy
20
+ Provides-Extra: dev
21
+ Requires-Dist: pytest; extra == "dev"
22
+ Dynamic: license-file
23
+
24
+ <h1 align="center">stochpylib</h1>
25
+
26
+ <p align="center">
27
+ <strong>Probability · Distributions · Monte Carlo — one coherent Python library.</strong><br>
28
+ A growing, from-scratch toolkit of stochastic computing: native implementations behind one
29
+ common interface, engineered to eventually replace stitching together
30
+ <code>scipy.stats</code>, <code>statsmodels</code>, <code>pymc</code>, <code>arch</code>,
31
+ <code>lifelines</code> and <code>copulas</code>.
32
+ </p>
33
+
34
+ ---
35
+
36
+ <p align="center">
37
+ <img src="https://img.shields.io/badge/python-3.10%2B-FF8C00?style=flat-square&labelColor=1A1A1A&logo=python&logoColor=white" alt="Python 3.10+">
38
+ <img src="https://img.shields.io/badge/%F0%9F%93%84%20license-MIT-8B5CF6?style=flat-square&labelColor=1A1A1A" alt="License: MIT">
39
+ <img src="https://img.shields.io/badge/tests-182%20passing-brightgreen?style=flat-square&labelColor=1A1A1A" alt="182 tests passing">
40
+ <a href="https://github.com/leon1706-lol/Stochpylib/actions/workflows/ci.yml"><img src="https://img.shields.io/github/actions/workflow/status/leon1706-lol/Stochpylib/ci.yml?branch=main&style=flat-square&labelColor=1A1A1A&label=CI&logo=githubactions&logoColor=white" alt="CI status"></a>
41
+ <a href="https://pypi.org/project/stochpylib/"><img src="https://img.shields.io/pypi/v/stochpylib?style=flat-square&labelColor=1A1A1A&color=FF8C00&logo=pypi&logoColor=white" alt="PyPI version"></a>
42
+ <img src="https://img.shields.io/badge/public%20names-106%20of%20794-FF8C00?style=flat-square&labelColor=1A1A1A" alt="106 of 794 spec names implemented">
43
+ </p>
44
+
45
+ <p align="center">
46
+ <img src="https://img.shields.io/badge/NumPy-4B5563?style=flat-square&labelColor=1A1A1A&logo=numpy&logoColor=white" alt="NumPy">
47
+ <img src="https://img.shields.io/badge/SciPy-4B5563?style=flat-square&labelColor=1A1A1A&logo=scipy&logoColor=white" alt="SciPy">
48
+ <img src="https://img.shields.io/badge/pytest-4B5563?style=flat-square&labelColor=1A1A1A&logo=pytest&logoColor=white" alt="pytest">
49
+ <img src="https://img.shields.io/badge/setuptools-4B5563?style=flat-square&labelColor=1A1A1A" alt="setuptools">
50
+ <img src="https://img.shields.io/badge/GitHub%20Actions-4B5563?style=flat-square&labelColor=1A1A1A&logo=githubactions&logoColor=white" alt="GitHub Actions">
51
+ <img src="https://img.shields.io/badge/spl%20CLI-black?style=flat-square&labelColor=1A1A1A&logo=gnu-bash&logoColor=white" alt="spl command-line interface">
52
+ </p>
53
+
54
+ ---
55
+
56
+ stochpylib is not a wrapper around existing statistical libraries — every distribution and
57
+ algorithm is implemented from scratch, with `scipy.special/optimize/integrate` used only as raw
58
+ numerical building blocks and `scipy.stats` serving as the independent test oracle. At its core
59
+ is a single load-bearing contract: every distribution exposes the same method set
60
+ (`.pdf()/.cdf()/.ppf()/.rvs()/.mean()/.var()/.skewness()/.kurtosis()/.entropy()/.mgf()/.cf()/.fit()/.ks_test()`),
61
+ every stochastic method takes a `random_state=` seed, and every Monte Carlo estimator returns a
62
+ shared result object carrying its point estimate together with an honest standard error and
63
+ confidence interval. Around that contract, three modules are live today: a **probability engine**
64
+ (sample spaces, Bayes' theorem, exact-integer combinatorics, independence testing), **47
65
+ distributions** across discrete/continuous/multivariate/heavy-tailed families — including stable
66
+ laws with Chambers–Mallows–Leckie sampling and numerically inverted characteristic functions —
67
+ and a **Monte Carlo suite** spanning quasi-random sequences (Sobol, Halton, Faure,
68
+ Niederreiter), variance-reduction techniques (antithetic, control variates, Latin hypercube,
69
+ conditioned MC, rejection control), and applications from option pricing validated against
70
+ Black–Scholes to reliability analysis driven by the library's own distribution objects. The
71
+ thesis this project exists to test: a complete stochastic-computing stack can live in one
72
+ coherent, well-tested package — the roadmap takes it onward through time series, Gaussian
73
+ processes, copulas, Lévy processes, MCMC and beyond (23 modules, ~794 public names planned).
74
+
75
+ ## Table of Contents
76
+
77
+ - [Quickstart](#quickstart)
78
+ - [Current Status](#current-status)
79
+ - [Download](#download)
80
+ - [Getting Started](#getting-started)
81
+ - [Requirements](#requirements)
82
+ - [CLI Reference](#cli-reference)
83
+ - [Project Layout](#project-layout)
84
+ - [Development Documentation](#development-documentation)
85
+ - [Test Suite](#test-suite)
86
+ - [Release Process](#release-process)
87
+ - [Roadmap](#roadmap)
88
+ - [Contributing](#contributing)
89
+ - [License](#license)
90
+
91
+ ## Quickstart
92
+
93
+ ```python
94
+ from stochpylib.probability import bayes_theorem, total_probability
95
+
96
+ # Classic disease-screening example: 1% prevalence, 99% sensitivity, 5% false-positive rate.
97
+ p_positive = total_probability((0.99, 0.01), (0.05, 0.99))
98
+ p_disease_given_positive = bayes_theorem(0.01, 0.99, p_positive)
99
+ print(round(p_disease_given_positive, 4)) # 0.1667
100
+ ```
101
+
102
+ ```python
103
+ from stochpylib.distributions import Normal, Weibull
104
+ from stochpylib.montecarlo import SobolSequence, AntitheticVariates
105
+
106
+ d = Normal(0.0, 1.0)
107
+ d.pdf(0.0); d.cdf(1.96); d.ppf(0.975); d.rvs(100, random_state=0)
108
+
109
+ fitted = Weibull.fit(lifetimes) # maximum likelihood from data
110
+ stat, p_value = fitted.ks_test(data) # goodness of fit
111
+
112
+ pts = SobolSequence(dim=5).generate(10_000) # low-discrepancy points
113
+ price = AntitheticVariates(n_simulations=100_000).price_european_call(
114
+ S=100, K=100, T=1, r=0.05, sigma=0.2) # option pricing
115
+ ```
116
+
117
+ ## Current Status
118
+
119
+ Early development — three modules implemented so far:
120
+
121
+ | Module | Public names | What's inside |
122
+ |---|---|---|
123
+ | `stochpylib.probability` | 21 | sample spaces, events, conditional probability, Bayes' theorem, combinatorics (factorial … derangements, Stirling, Bell, Catalan), independence checks |
124
+ | `stochpylib.distributions` | 60 | 47 distributions (discrete, continuous, multivariate, heavy-tailed) behind the common interface |
125
+ | `stochpylib.montecarlo` | 25 | quasi-random sequences, crude/QMC/importance/rejection/stratified estimators, variance reduction, applications |
126
+
127
+ Exact progress against the full design spec lives in
128
+ [`development/Implementation-Checklist.md`](development/Implementation-Checklist.md)
129
+ (currently **106 / 794 public names**).
130
+
131
+ ## Download
132
+
133
+ If you just want to *use* stochpylib rather than develop on it, no source checkout is needed:
134
+
135
+ ```bash
136
+ pip install stochpylib
137
+ spl --help # overview of everything the library offers
138
+ ```
139
+
140
+ > The PyPI release lands with the first tagged version (`v0.1.0`); until then the badge above
141
+ > will show "not found". For local development from this repository, `pip install -e .`
142
+ > registers the same `spl` command straight from source instead:
143
+
144
+ ```bash
145
+ git clone https://github.com/leon1706-lol/Stochpylib.git
146
+ cd Stochpylib
147
+ pip install -e .
148
+ ```
149
+
150
+ ## Getting Started
151
+
152
+ For local development (this repo cloned, a virtual environment active):
153
+
154
+ ```bash
155
+ pip install -e ".[dev]" # runtime deps + pytest
156
+ pytest tests/ -v # full test suite must be green before you start changing things
157
+ spl --version # verify your editable install
158
+ spl --test # embedded self-check (106 checks), no pytest needed
159
+ ```
160
+
161
+ Then implement or improve one module at a time and run the wrap-up procedure described in
162
+ [`CONTRIBUTING.md`](CONTRIBUTING.md).
163
+
164
+ ## Requirements
165
+
166
+ - **Python ≥ 3.10**
167
+ - **NumPy** and **SciPy** (the only runtime dependencies)
168
+ - **pytest** for the development extras (`pip install -e ".[dev]"`)
169
+ - No compilers, no GPU, no other system packages — pure Python/NumPy/SciPy by design
170
+
171
+ ## CLI Reference
172
+
173
+ Every install (PyPI wheel or `pip install -e .`) registers one console command, `spl`:
174
+
175
+ ### `spl --help`
176
+
177
+ Prints a full inventory of the installed library: which modules are available, all public
178
+ functions per module, every distribution class (generated dynamically from the package, so it
179
+ never goes stale), the common distribution interface, and a runnable quick-start snippet.
180
+ Running bare `spl` shows the same thing.
181
+
182
+ ### `spl --version`
183
+
184
+ ```bash
185
+ $ spl --version
186
+ 0.1.0
187
+ ```
188
+
189
+ Prints the installed version — reads pip package metadata, falling back to the in-code version
190
+ when not installed through pip.
191
+
192
+ ### `spl --test`
193
+
194
+ Runs the embedded self-check suite shipped inside the wheel (**106 checks**): package sanity,
195
+ one closed-form spot check per distribution family, Monte Carlo convergence sanity. This works
196
+ after any `pip install` — no pytest, no source checkout — making it the quickest way to verify
197
+ an installation. Exits non-zero on any failure.
198
+
199
+ ## Project Layout
200
+
201
+ - [`stochpylib/`](stochpylib/) — the installable package, one subpackage per module
202
+ ([`probability/`](stochpylib/probability/README.md),
203
+ [`distributions/`](stochpylib/distributions/README.md),
204
+ [`montecarlo/`](stochpylib/montecarlo/README.md)), plus `cli.py` and `selftest.py`
205
+ - [`tests/`](tests/README.md) — one `tests/<module>/tests.py` per module, outside the package
206
+ - [`development/`](development/) — build history & process docs (see below)
207
+ - `.github/workflows/` — CI matrix (Python 3.10–3.13), tag-triggered PyPI publishing
208
+ (Trusted Publisher/OIDC, no stored tokens), automatic GitHub Releases
209
+ - The full design-spec vault (`Stochpylib-Obsidian-Vault/`) is maintained privately and is not
210
+ part of this repository
211
+
212
+ ## Development Documentation
213
+
214
+ Everything a contributor or maintainer needs lives in committed docs:
215
+
216
+ - [`CONTRIBUTING.md`](CONTRIBUTING.md) — dev setup, ground rules, **semver & deprecation policy**, PR checklist
217
+ - [`CODE_OF_CONDUCT.md`](CODE_OF_CONDUCT.md) — Contributor Covenant 2.1
218
+ - [`SECURITY.md`](SECURITY.md) — private vulnerability reporting (72 h acknowledgment)
219
+ - [`development/Development.md`](development/Development.md) — layout decisions & workflow notes
220
+ - [`development/CHANGELOG.md`](development/CHANGELOG.md) — append-only log, one entry per build phase
221
+ - [`development/Probleme.md`](development/Probleme.md) — bug audit log with severity scores (11 entries so far)
222
+ - [`development/Implementation-Checklist.md`](development/Implementation-Checklist.md) — every planned public name as a checkbox
223
+
224
+ ## Test Suite
225
+
226
+ ```bash
227
+ pytest tests/ -v
228
+ ```
229
+
230
+ **182 passed / 2 skipped** as of the `montecarlo` module. Tests are deterministic (fixed seeds
231
+ everywhere), live outside the installed package, and use `scipy.stats` as the reference oracle.
232
+ Statistical assertions are set at ≥ 3 standard errors so results are stable while staying
233
+ meaningful. Additionally, `spl --test` re-verifies any installation in seconds.
234
+
235
+ ## Release Process
236
+
237
+ Releases are fully automated from tags:
238
+
239
+ 1. Update the version in `pyproject.toml` **and** `stochpylib/__init__.py` (semver — see the
240
+ policy in [`CONTRIBUTING.md`](CONTRIBUTING.md))
241
+ 2. Tag and push:
242
+ ```bash
243
+ git tag v0.1.0 && git push origin v0.1.0
244
+ ```
245
+ 3. CI runs the full test matrix, builds sdist + wheel, smoke-verifies the wheel
246
+ (`spl --version`, `spl --test`) and publishes to PyPI via Trusted Publisher (OIDC — no API
247
+ tokens stored anywhere); a second workflow creates the matching GitHub Release with
248
+ auto-generated changelog notes
249
+
250
+ Prerequisite for step 3: configure the Trusted Publisher once under pypi.org → your project →
251
+ Publishing.
252
+
253
+ ## Roadmap
254
+
255
+ Twenty modules remain on the spec (in rough implementation order):
256
+ time series, Gaussian processes, copulas, survival analysis, queueing theory, information
257
+ theory, Lévy processes, financial stochastics, advanced MCMC, Bayesian inference, statistics,
258
+ nonparametric methods, robust statistics, numerical methods, random matrix theory, spatial
259
+ statistics, optimization, experimental design, visualization, and utilities. Each lands with the same bar: native implementations, the shared
260
+ interface conventions, full tests against independent oracles, and honest documentation of
261
+ deviations.
262
+
263
+ ## Contributing
264
+
265
+ Issues and PRs welcome! Start with [`CONTRIBUTING.md`](CONTRIBUTING.md) — it covers the ground
266
+ rules (no `scipy.stats` wrapping in library code, the common interface contract, where tests
267
+ live) and the versioning/deprecation policy. Bug reports go through the issue templates;
268
+ security issues privately per [`SECURITY.md`](SECURITY.md). This project follows
269
+ [`CODE_OF_CONDUCT.md`](CODE_OF_CONDUCT.md).
270
+
271
+ ## License
272
+
273
+ [MIT](LICENSE) © Leon Schwarzkopf
274
+
275
+ ---
276
+
277
+ <p align="center">
278
+ Built by <strong>Leon Schwarzkopf</strong>, <a href="mailto:leonschwarzkopf08@gmail.com">leonschwarzkopf08@gmail.com</a>
279
+ </p>
280
+
281
+ ---
282
+
283
+ <div align="center">
284
+ <sub>stochpylib</sub>
285
+ </div>
@@ -0,0 +1,262 @@
1
+ <h1 align="center">stochpylib</h1>
2
+
3
+ <p align="center">
4
+ <strong>Probability · Distributions · Monte Carlo — one coherent Python library.</strong><br>
5
+ A growing, from-scratch toolkit of stochastic computing: native implementations behind one
6
+ common interface, engineered to eventually replace stitching together
7
+ <code>scipy.stats</code>, <code>statsmodels</code>, <code>pymc</code>, <code>arch</code>,
8
+ <code>lifelines</code> and <code>copulas</code>.
9
+ </p>
10
+
11
+ ---
12
+
13
+ <p align="center">
14
+ <img src="https://img.shields.io/badge/python-3.10%2B-FF8C00?style=flat-square&labelColor=1A1A1A&logo=python&logoColor=white" alt="Python 3.10+">
15
+ <img src="https://img.shields.io/badge/%F0%9F%93%84%20license-MIT-8B5CF6?style=flat-square&labelColor=1A1A1A" alt="License: MIT">
16
+ <img src="https://img.shields.io/badge/tests-182%20passing-brightgreen?style=flat-square&labelColor=1A1A1A" alt="182 tests passing">
17
+ <a href="https://github.com/leon1706-lol/Stochpylib/actions/workflows/ci.yml"><img src="https://img.shields.io/github/actions/workflow/status/leon1706-lol/Stochpylib/ci.yml?branch=main&style=flat-square&labelColor=1A1A1A&label=CI&logo=githubactions&logoColor=white" alt="CI status"></a>
18
+ <a href="https://pypi.org/project/stochpylib/"><img src="https://img.shields.io/pypi/v/stochpylib?style=flat-square&labelColor=1A1A1A&color=FF8C00&logo=pypi&logoColor=white" alt="PyPI version"></a>
19
+ <img src="https://img.shields.io/badge/public%20names-106%20of%20794-FF8C00?style=flat-square&labelColor=1A1A1A" alt="106 of 794 spec names implemented">
20
+ </p>
21
+
22
+ <p align="center">
23
+ <img src="https://img.shields.io/badge/NumPy-4B5563?style=flat-square&labelColor=1A1A1A&logo=numpy&logoColor=white" alt="NumPy">
24
+ <img src="https://img.shields.io/badge/SciPy-4B5563?style=flat-square&labelColor=1A1A1A&logo=scipy&logoColor=white" alt="SciPy">
25
+ <img src="https://img.shields.io/badge/pytest-4B5563?style=flat-square&labelColor=1A1A1A&logo=pytest&logoColor=white" alt="pytest">
26
+ <img src="https://img.shields.io/badge/setuptools-4B5563?style=flat-square&labelColor=1A1A1A" alt="setuptools">
27
+ <img src="https://img.shields.io/badge/GitHub%20Actions-4B5563?style=flat-square&labelColor=1A1A1A&logo=githubactions&logoColor=white" alt="GitHub Actions">
28
+ <img src="https://img.shields.io/badge/spl%20CLI-black?style=flat-square&labelColor=1A1A1A&logo=gnu-bash&logoColor=white" alt="spl command-line interface">
29
+ </p>
30
+
31
+ ---
32
+
33
+ stochpylib is not a wrapper around existing statistical libraries — every distribution and
34
+ algorithm is implemented from scratch, with `scipy.special/optimize/integrate` used only as raw
35
+ numerical building blocks and `scipy.stats` serving as the independent test oracle. At its core
36
+ is a single load-bearing contract: every distribution exposes the same method set
37
+ (`.pdf()/.cdf()/.ppf()/.rvs()/.mean()/.var()/.skewness()/.kurtosis()/.entropy()/.mgf()/.cf()/.fit()/.ks_test()`),
38
+ every stochastic method takes a `random_state=` seed, and every Monte Carlo estimator returns a
39
+ shared result object carrying its point estimate together with an honest standard error and
40
+ confidence interval. Around that contract, three modules are live today: a **probability engine**
41
+ (sample spaces, Bayes' theorem, exact-integer combinatorics, independence testing), **47
42
+ distributions** across discrete/continuous/multivariate/heavy-tailed families — including stable
43
+ laws with Chambers–Mallows–Leckie sampling and numerically inverted characteristic functions —
44
+ and a **Monte Carlo suite** spanning quasi-random sequences (Sobol, Halton, Faure,
45
+ Niederreiter), variance-reduction techniques (antithetic, control variates, Latin hypercube,
46
+ conditioned MC, rejection control), and applications from option pricing validated against
47
+ Black–Scholes to reliability analysis driven by the library's own distribution objects. The
48
+ thesis this project exists to test: a complete stochastic-computing stack can live in one
49
+ coherent, well-tested package — the roadmap takes it onward through time series, Gaussian
50
+ processes, copulas, Lévy processes, MCMC and beyond (23 modules, ~794 public names planned).
51
+
52
+ ## Table of Contents
53
+
54
+ - [Quickstart](#quickstart)
55
+ - [Current Status](#current-status)
56
+ - [Download](#download)
57
+ - [Getting Started](#getting-started)
58
+ - [Requirements](#requirements)
59
+ - [CLI Reference](#cli-reference)
60
+ - [Project Layout](#project-layout)
61
+ - [Development Documentation](#development-documentation)
62
+ - [Test Suite](#test-suite)
63
+ - [Release Process](#release-process)
64
+ - [Roadmap](#roadmap)
65
+ - [Contributing](#contributing)
66
+ - [License](#license)
67
+
68
+ ## Quickstart
69
+
70
+ ```python
71
+ from stochpylib.probability import bayes_theorem, total_probability
72
+
73
+ # Classic disease-screening example: 1% prevalence, 99% sensitivity, 5% false-positive rate.
74
+ p_positive = total_probability((0.99, 0.01), (0.05, 0.99))
75
+ p_disease_given_positive = bayes_theorem(0.01, 0.99, p_positive)
76
+ print(round(p_disease_given_positive, 4)) # 0.1667
77
+ ```
78
+
79
+ ```python
80
+ from stochpylib.distributions import Normal, Weibull
81
+ from stochpylib.montecarlo import SobolSequence, AntitheticVariates
82
+
83
+ d = Normal(0.0, 1.0)
84
+ d.pdf(0.0); d.cdf(1.96); d.ppf(0.975); d.rvs(100, random_state=0)
85
+
86
+ fitted = Weibull.fit(lifetimes) # maximum likelihood from data
87
+ stat, p_value = fitted.ks_test(data) # goodness of fit
88
+
89
+ pts = SobolSequence(dim=5).generate(10_000) # low-discrepancy points
90
+ price = AntitheticVariates(n_simulations=100_000).price_european_call(
91
+ S=100, K=100, T=1, r=0.05, sigma=0.2) # option pricing
92
+ ```
93
+
94
+ ## Current Status
95
+
96
+ Early development — three modules implemented so far:
97
+
98
+ | Module | Public names | What's inside |
99
+ |---|---|---|
100
+ | `stochpylib.probability` | 21 | sample spaces, events, conditional probability, Bayes' theorem, combinatorics (factorial … derangements, Stirling, Bell, Catalan), independence checks |
101
+ | `stochpylib.distributions` | 60 | 47 distributions (discrete, continuous, multivariate, heavy-tailed) behind the common interface |
102
+ | `stochpylib.montecarlo` | 25 | quasi-random sequences, crude/QMC/importance/rejection/stratified estimators, variance reduction, applications |
103
+
104
+ Exact progress against the full design spec lives in
105
+ [`development/Implementation-Checklist.md`](development/Implementation-Checklist.md)
106
+ (currently **106 / 794 public names**).
107
+
108
+ ## Download
109
+
110
+ If you just want to *use* stochpylib rather than develop on it, no source checkout is needed:
111
+
112
+ ```bash
113
+ pip install stochpylib
114
+ spl --help # overview of everything the library offers
115
+ ```
116
+
117
+ > The PyPI release lands with the first tagged version (`v0.1.0`); until then the badge above
118
+ > will show "not found". For local development from this repository, `pip install -e .`
119
+ > registers the same `spl` command straight from source instead:
120
+
121
+ ```bash
122
+ git clone https://github.com/leon1706-lol/Stochpylib.git
123
+ cd Stochpylib
124
+ pip install -e .
125
+ ```
126
+
127
+ ## Getting Started
128
+
129
+ For local development (this repo cloned, a virtual environment active):
130
+
131
+ ```bash
132
+ pip install -e ".[dev]" # runtime deps + pytest
133
+ pytest tests/ -v # full test suite must be green before you start changing things
134
+ spl --version # verify your editable install
135
+ spl --test # embedded self-check (106 checks), no pytest needed
136
+ ```
137
+
138
+ Then implement or improve one module at a time and run the wrap-up procedure described in
139
+ [`CONTRIBUTING.md`](CONTRIBUTING.md).
140
+
141
+ ## Requirements
142
+
143
+ - **Python ≥ 3.10**
144
+ - **NumPy** and **SciPy** (the only runtime dependencies)
145
+ - **pytest** for the development extras (`pip install -e ".[dev]"`)
146
+ - No compilers, no GPU, no other system packages — pure Python/NumPy/SciPy by design
147
+
148
+ ## CLI Reference
149
+
150
+ Every install (PyPI wheel or `pip install -e .`) registers one console command, `spl`:
151
+
152
+ ### `spl --help`
153
+
154
+ Prints a full inventory of the installed library: which modules are available, all public
155
+ functions per module, every distribution class (generated dynamically from the package, so it
156
+ never goes stale), the common distribution interface, and a runnable quick-start snippet.
157
+ Running bare `spl` shows the same thing.
158
+
159
+ ### `spl --version`
160
+
161
+ ```bash
162
+ $ spl --version
163
+ 0.1.0
164
+ ```
165
+
166
+ Prints the installed version — reads pip package metadata, falling back to the in-code version
167
+ when not installed through pip.
168
+
169
+ ### `spl --test`
170
+
171
+ Runs the embedded self-check suite shipped inside the wheel (**106 checks**): package sanity,
172
+ one closed-form spot check per distribution family, Monte Carlo convergence sanity. This works
173
+ after any `pip install` — no pytest, no source checkout — making it the quickest way to verify
174
+ an installation. Exits non-zero on any failure.
175
+
176
+ ## Project Layout
177
+
178
+ - [`stochpylib/`](stochpylib/) — the installable package, one subpackage per module
179
+ ([`probability/`](stochpylib/probability/README.md),
180
+ [`distributions/`](stochpylib/distributions/README.md),
181
+ [`montecarlo/`](stochpylib/montecarlo/README.md)), plus `cli.py` and `selftest.py`
182
+ - [`tests/`](tests/README.md) — one `tests/<module>/tests.py` per module, outside the package
183
+ - [`development/`](development/) — build history & process docs (see below)
184
+ - `.github/workflows/` — CI matrix (Python 3.10–3.13), tag-triggered PyPI publishing
185
+ (Trusted Publisher/OIDC, no stored tokens), automatic GitHub Releases
186
+ - The full design-spec vault (`Stochpylib-Obsidian-Vault/`) is maintained privately and is not
187
+ part of this repository
188
+
189
+ ## Development Documentation
190
+
191
+ Everything a contributor or maintainer needs lives in committed docs:
192
+
193
+ - [`CONTRIBUTING.md`](CONTRIBUTING.md) — dev setup, ground rules, **semver & deprecation policy**, PR checklist
194
+ - [`CODE_OF_CONDUCT.md`](CODE_OF_CONDUCT.md) — Contributor Covenant 2.1
195
+ - [`SECURITY.md`](SECURITY.md) — private vulnerability reporting (72 h acknowledgment)
196
+ - [`development/Development.md`](development/Development.md) — layout decisions & workflow notes
197
+ - [`development/CHANGELOG.md`](development/CHANGELOG.md) — append-only log, one entry per build phase
198
+ - [`development/Probleme.md`](development/Probleme.md) — bug audit log with severity scores (11 entries so far)
199
+ - [`development/Implementation-Checklist.md`](development/Implementation-Checklist.md) — every planned public name as a checkbox
200
+
201
+ ## Test Suite
202
+
203
+ ```bash
204
+ pytest tests/ -v
205
+ ```
206
+
207
+ **182 passed / 2 skipped** as of the `montecarlo` module. Tests are deterministic (fixed seeds
208
+ everywhere), live outside the installed package, and use `scipy.stats` as the reference oracle.
209
+ Statistical assertions are set at ≥ 3 standard errors so results are stable while staying
210
+ meaningful. Additionally, `spl --test` re-verifies any installation in seconds.
211
+
212
+ ## Release Process
213
+
214
+ Releases are fully automated from tags:
215
+
216
+ 1. Update the version in `pyproject.toml` **and** `stochpylib/__init__.py` (semver — see the
217
+ policy in [`CONTRIBUTING.md`](CONTRIBUTING.md))
218
+ 2. Tag and push:
219
+ ```bash
220
+ git tag v0.1.0 && git push origin v0.1.0
221
+ ```
222
+ 3. CI runs the full test matrix, builds sdist + wheel, smoke-verifies the wheel
223
+ (`spl --version`, `spl --test`) and publishes to PyPI via Trusted Publisher (OIDC — no API
224
+ tokens stored anywhere); a second workflow creates the matching GitHub Release with
225
+ auto-generated changelog notes
226
+
227
+ Prerequisite for step 3: configure the Trusted Publisher once under pypi.org → your project →
228
+ Publishing.
229
+
230
+ ## Roadmap
231
+
232
+ Twenty modules remain on the spec (in rough implementation order):
233
+ time series, Gaussian processes, copulas, survival analysis, queueing theory, information
234
+ theory, Lévy processes, financial stochastics, advanced MCMC, Bayesian inference, statistics,
235
+ nonparametric methods, robust statistics, numerical methods, random matrix theory, spatial
236
+ statistics, optimization, experimental design, visualization, and utilities. Each lands with the same bar: native implementations, the shared
237
+ interface conventions, full tests against independent oracles, and honest documentation of
238
+ deviations.
239
+
240
+ ## Contributing
241
+
242
+ Issues and PRs welcome! Start with [`CONTRIBUTING.md`](CONTRIBUTING.md) — it covers the ground
243
+ rules (no `scipy.stats` wrapping in library code, the common interface contract, where tests
244
+ live) and the versioning/deprecation policy. Bug reports go through the issue templates;
245
+ security issues privately per [`SECURITY.md`](SECURITY.md). This project follows
246
+ [`CODE_OF_CONDUCT.md`](CODE_OF_CONDUCT.md).
247
+
248
+ ## License
249
+
250
+ [MIT](LICENSE) © Leon Schwarzkopf
251
+
252
+ ---
253
+
254
+ <p align="center">
255
+ Built by <strong>Leon Schwarzkopf</strong>, <a href="mailto:leonschwarzkopf08@gmail.com">leonschwarzkopf08@gmail.com</a>
256
+ </p>
257
+
258
+ ---
259
+
260
+ <div align="center">
261
+ <sub>stochpylib</sub>
262
+ </div>
@@ -0,0 +1,40 @@
1
+ [build-system]
2
+ requires = ["setuptools>=68.0"]
3
+ build-backend = "setuptools.build_meta"
4
+
5
+ [project]
6
+ name = "stochpylib"
7
+ version = "0.1.0"
8
+ description = "A Python library for probability, distributions, stochastic processes, and statistical computing"
9
+ readme = "README.md"
10
+ requires-python = ">=3.10"
11
+ license = "MIT"
12
+ license-files = ["LICENSE"]
13
+ authors = [{ name = "Leon Schwarzkopf" }]
14
+ classifiers = [
15
+ "Development Status :: 2 - Pre-Alpha",
16
+ "Intended Audience :: Science/Research",
17
+ "Programming Language :: Python :: 3",
18
+ "Programming Language :: Python :: 3.10",
19
+ "Programming Language :: Python :: 3.11",
20
+ "Programming Language :: Python :: 3.12",
21
+ "Programming Language :: Python :: 3.13",
22
+ "Topic :: Scientific/Engineering :: Mathematics",
23
+ ]
24
+ dependencies = [
25
+ "numpy",
26
+ "scipy",
27
+ ]
28
+
29
+ [project.optional-dependencies]
30
+ dev = ["pytest"]
31
+
32
+ [project.scripts]
33
+ spl = "stochpylib.cli:main"
34
+
35
+ [tool.setuptools.packages.find]
36
+ include = ["stochpylib*"]
37
+
38
+ [tool.pytest.ini_options]
39
+ testpaths = ["tests"]
40
+ python_files = ["tests.py"]
@@ -0,0 +1,4 @@
1
+ [egg_info]
2
+ tag_build =
3
+ tag_date = 0
4
+
@@ -0,0 +1,5 @@
1
+ from stochpylib import distributions, montecarlo, probability
2
+
3
+ __all__ = ["distributions", "montecarlo", "probability"]
4
+
5
+ __version__ = "0.1.0"