samplepaths 0.1.0__tar.gz → 0.1.1__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 (111) hide show
  1. samplepaths-0.1.1/PKG-INFO +204 -0
  2. samplepaths-0.1.1/README.md +172 -0
  3. {samplepaths-0.1.0 → samplepaths-0.1.1}/pyproject.toml +9 -4
  4. samplepaths-0.1.0/PKG-INFO +0 -159
  5. samplepaths-0.1.0/README.rst +0 -127
  6. {samplepaths-0.1.0 → samplepaths-0.1.1}/.gitignore +0 -0
  7. {samplepaths-0.1.0 → samplepaths-0.1.1}/LICENSE +0 -0
  8. {samplepaths-0.1.0 → samplepaths-0.1.1}/src/samplepaths/__init__.py +0 -0
  9. {samplepaths-0.1.0 → samplepaths-0.1.1}/src/samplepaths/base/__init__.py +0 -0
  10. {samplepaths-0.1.0 → samplepaths-0.1.1}/src/samplepaths/base/base_process.py +0 -0
  11. {samplepaths-0.1.0 → samplepaths-0.1.1}/src/samplepaths/base/base_sequence_process.py +0 -0
  12. {samplepaths-0.1.0 → samplepaths-0.1.1}/src/samplepaths/base/base_time_process.py +0 -0
  13. {samplepaths-0.1.0 → samplepaths-0.1.1}/src/samplepaths/continuous/__init__.py +0 -0
  14. {samplepaths-0.1.0 → samplepaths-0.1.1}/src/samplepaths/continuous/bessel_process.py +0 -0
  15. {samplepaths-0.1.0 → samplepaths-0.1.1}/src/samplepaths/continuous/brownian_bridge.py +0 -0
  16. {samplepaths-0.1.0 → samplepaths-0.1.1}/src/samplepaths/continuous/brownian_excursion.py +0 -0
  17. {samplepaths-0.1.0 → samplepaths-0.1.1}/src/samplepaths/continuous/brownian_meander.py +0 -0
  18. {samplepaths-0.1.0 → samplepaths-0.1.1}/src/samplepaths/continuous/brownian_motion.py +0 -0
  19. {samplepaths-0.1.0 → samplepaths-0.1.1}/src/samplepaths/continuous/cauchy_process.py +0 -0
  20. {samplepaths-0.1.0 → samplepaths-0.1.1}/src/samplepaths/continuous/fractional_brownian_motion.py +0 -0
  21. {samplepaths-0.1.0 → samplepaths-0.1.1}/src/samplepaths/continuous/gamma_process.py +0 -0
  22. {samplepaths-0.1.0 → samplepaths-0.1.1}/src/samplepaths/continuous/geometric_brownian_motion.py +0 -0
  23. {samplepaths-0.1.0 → samplepaths-0.1.1}/src/samplepaths/continuous/inverse_gaussian_process.py +0 -0
  24. {samplepaths-0.1.0 → samplepaths-0.1.1}/src/samplepaths/continuous/mixed_poisson_process.py +0 -0
  25. {samplepaths-0.1.0 → samplepaths-0.1.1}/src/samplepaths/continuous/multifractional_brownian_motion.py +0 -0
  26. {samplepaths-0.1.0 → samplepaths-0.1.1}/src/samplepaths/continuous/poisson_process.py +0 -0
  27. {samplepaths-0.1.0 → samplepaths-0.1.1}/src/samplepaths/continuous/squared_bessel_process.py +0 -0
  28. {samplepaths-0.1.0 → samplepaths-0.1.1}/src/samplepaths/continuous/variance_gamma_process.py +0 -0
  29. {samplepaths-0.1.0 → samplepaths-0.1.1}/src/samplepaths/continuous/wiener_process.py +0 -0
  30. {samplepaths-0.1.0 → samplepaths-0.1.1}/src/samplepaths/diffusion/__init__.py +0 -0
  31. {samplepaths-0.1.0 → samplepaths-0.1.1}/src/samplepaths/diffusion/constant_elasticity_variance_process.py +0 -0
  32. {samplepaths-0.1.0 → samplepaths-0.1.1}/src/samplepaths/diffusion/cox_ingersoll_ross_process.py +0 -0
  33. {samplepaths-0.1.0 → samplepaths-0.1.1}/src/samplepaths/diffusion/diffusion_process.py +0 -0
  34. {samplepaths-0.1.0 → samplepaths-0.1.1}/src/samplepaths/diffusion/extended_vasicek_process.py +0 -0
  35. {samplepaths-0.1.0 → samplepaths-0.1.1}/src/samplepaths/diffusion/ornstein_uhlenbeck_process.py +0 -0
  36. {samplepaths-0.1.0 → samplepaths-0.1.1}/src/samplepaths/diffusion/vasicek_process.py +0 -0
  37. {samplepaths-0.1.0 → samplepaths-0.1.1}/src/samplepaths/discrete/__init__.py +0 -0
  38. {samplepaths-0.1.0 → samplepaths-0.1.1}/src/samplepaths/discrete/bernoulli_process.py +0 -0
  39. {samplepaths-0.1.0 → samplepaths-0.1.1}/src/samplepaths/discrete/chinese_restaurant_process.py +0 -0
  40. {samplepaths-0.1.0 → samplepaths-0.1.1}/src/samplepaths/discrete/dirichlet_process.py +0 -0
  41. {samplepaths-0.1.0 → samplepaths-0.1.1}/src/samplepaths/discrete/markov_chain.py +0 -0
  42. {samplepaths-0.1.0 → samplepaths-0.1.1}/src/samplepaths/discrete/moran_process.py +0 -0
  43. {samplepaths-0.1.0 → samplepaths-0.1.1}/src/samplepaths/discrete/random_walk.py +0 -0
  44. {samplepaths-0.1.0 → samplepaths-0.1.1}/src/samplepaths/noise/__init__.py +0 -0
  45. {samplepaths-0.1.0 → samplepaths-0.1.1}/src/samplepaths/noise/colored/__init__.py +0 -0
  46. {samplepaths-0.1.0 → samplepaths-0.1.1}/src/samplepaths/noise/colored/blue_noise.py +0 -0
  47. {samplepaths-0.1.0 → samplepaths-0.1.1}/src/samplepaths/noise/colored/brownian_noise.py +0 -0
  48. {samplepaths-0.1.0 → samplepaths-0.1.1}/src/samplepaths/noise/colored/colored_noise.py +0 -0
  49. {samplepaths-0.1.0 → samplepaths-0.1.1}/src/samplepaths/noise/colored/pink_noise.py +0 -0
  50. {samplepaths-0.1.0 → samplepaths-0.1.1}/src/samplepaths/noise/colored/red_noise.py +0 -0
  51. {samplepaths-0.1.0 → samplepaths-0.1.1}/src/samplepaths/noise/colored/violet_noise.py +0 -0
  52. {samplepaths-0.1.0 → samplepaths-0.1.1}/src/samplepaths/noise/colored/white_noise.py +0 -0
  53. {samplepaths-0.1.0 → samplepaths-0.1.1}/src/samplepaths/noise/fractional_gaussian_noise.py +0 -0
  54. {samplepaths-0.1.0 → samplepaths-0.1.1}/src/samplepaths/noise/gaussian_noise.py +0 -0
  55. {samplepaths-0.1.0 → samplepaths-0.1.1}/src/samplepaths/py.typed +0 -0
  56. {samplepaths-0.1.0 → samplepaths-0.1.1}/src/samplepaths/random.py +0 -0
  57. {samplepaths-0.1.0 → samplepaths-0.1.1}/src/samplepaths/utils/__init__.py +0 -0
  58. {samplepaths-0.1.0 → samplepaths-0.1.1}/src/samplepaths/utils/validation.py +0 -0
  59. {samplepaths-0.1.0 → samplepaths-0.1.1}/tests/__init__.py +0 -0
  60. {samplepaths-0.1.0 → samplepaths-0.1.1}/tests/base/__init__.py +0 -0
  61. {samplepaths-0.1.0 → samplepaths-0.1.1}/tests/base/test_base_process.py +0 -0
  62. {samplepaths-0.1.0 → samplepaths-0.1.1}/tests/base/test_base_sequence_process.py +0 -0
  63. {samplepaths-0.1.0 → samplepaths-0.1.1}/tests/base/test_base_time_process.py +0 -0
  64. {samplepaths-0.1.0 → samplepaths-0.1.1}/tests/continuous/__init__.py +0 -0
  65. {samplepaths-0.1.0 → samplepaths-0.1.1}/tests/continuous/test_bessel_process.py +0 -0
  66. {samplepaths-0.1.0 → samplepaths-0.1.1}/tests/continuous/test_brownian_bridge.py +0 -0
  67. {samplepaths-0.1.0 → samplepaths-0.1.1}/tests/continuous/test_brownian_excursion.py +0 -0
  68. {samplepaths-0.1.0 → samplepaths-0.1.1}/tests/continuous/test_brownian_meander.py +0 -0
  69. {samplepaths-0.1.0 → samplepaths-0.1.1}/tests/continuous/test_brownian_motion.py +0 -0
  70. {samplepaths-0.1.0 → samplepaths-0.1.1}/tests/continuous/test_cauchy_process.py +0 -0
  71. {samplepaths-0.1.0 → samplepaths-0.1.1}/tests/continuous/test_fractional_brownian_motion.py +0 -0
  72. {samplepaths-0.1.0 → samplepaths-0.1.1}/tests/continuous/test_gamma_process.py +0 -0
  73. {samplepaths-0.1.0 → samplepaths-0.1.1}/tests/continuous/test_geometric_brownian_motion.py +0 -0
  74. {samplepaths-0.1.0 → samplepaths-0.1.1}/tests/continuous/test_inverse_gaussian_process.py +0 -0
  75. {samplepaths-0.1.0 → samplepaths-0.1.1}/tests/continuous/test_mixed_poisson_process.py +0 -0
  76. {samplepaths-0.1.0 → samplepaths-0.1.1}/tests/continuous/test_multifractional_brownian_motion.py +0 -0
  77. {samplepaths-0.1.0 → samplepaths-0.1.1}/tests/continuous/test_poisson_process.py +0 -0
  78. {samplepaths-0.1.0 → samplepaths-0.1.1}/tests/continuous/test_squared_bessel_process.py +0 -0
  79. {samplepaths-0.1.0 → samplepaths-0.1.1}/tests/continuous/test_variance_gamma_process.py +0 -0
  80. {samplepaths-0.1.0 → samplepaths-0.1.1}/tests/continuous/test_wiener_process.py +0 -0
  81. {samplepaths-0.1.0 → samplepaths-0.1.1}/tests/diffusion/__init__.py +0 -0
  82. {samplepaths-0.1.0 → samplepaths-0.1.1}/tests/diffusion/test_constant_elasticity_variance_process.py +0 -0
  83. {samplepaths-0.1.0 → samplepaths-0.1.1}/tests/diffusion/test_cox_ingersoll_ross_process.py +0 -0
  84. {samplepaths-0.1.0 → samplepaths-0.1.1}/tests/diffusion/test_diffusion_process.py +0 -0
  85. {samplepaths-0.1.0 → samplepaths-0.1.1}/tests/diffusion/test_extended_vasicek_process.py +0 -0
  86. {samplepaths-0.1.0 → samplepaths-0.1.1}/tests/diffusion/test_ornstein_uhlenbeck_process.py +0 -0
  87. {samplepaths-0.1.0 → samplepaths-0.1.1}/tests/diffusion/test_vasicek_process.py +0 -0
  88. {samplepaths-0.1.0 → samplepaths-0.1.1}/tests/discrete/__init__.py +0 -0
  89. {samplepaths-0.1.0 → samplepaths-0.1.1}/tests/discrete/test_bernoulli_process.py +0 -0
  90. {samplepaths-0.1.0 → samplepaths-0.1.1}/tests/discrete/test_chinese_restaurant_process.py +0 -0
  91. {samplepaths-0.1.0 → samplepaths-0.1.1}/tests/discrete/test_dirichlet_process.py +0 -0
  92. {samplepaths-0.1.0 → samplepaths-0.1.1}/tests/discrete/test_markov_chain.py +0 -0
  93. {samplepaths-0.1.0 → samplepaths-0.1.1}/tests/discrete/test_moran_process.py +0 -0
  94. {samplepaths-0.1.0 → samplepaths-0.1.1}/tests/discrete/test_random_walk.py +0 -0
  95. {samplepaths-0.1.0 → samplepaths-0.1.1}/tests/noise/__init__.py +0 -0
  96. {samplepaths-0.1.0 → samplepaths-0.1.1}/tests/noise/colored/__init__.py +0 -0
  97. {samplepaths-0.1.0 → samplepaths-0.1.1}/tests/noise/colored/test_blue_noise.py +0 -0
  98. {samplepaths-0.1.0 → samplepaths-0.1.1}/tests/noise/colored/test_brownian_noise.py +0 -0
  99. {samplepaths-0.1.0 → samplepaths-0.1.1}/tests/noise/colored/test_colored_noise.py +0 -0
  100. {samplepaths-0.1.0 → samplepaths-0.1.1}/tests/noise/colored/test_pink_noise.py +0 -0
  101. {samplepaths-0.1.0 → samplepaths-0.1.1}/tests/noise/colored/test_red_noise.py +0 -0
  102. {samplepaths-0.1.0 → samplepaths-0.1.1}/tests/noise/colored/test_violet_noise.py +0 -0
  103. {samplepaths-0.1.0 → samplepaths-0.1.1}/tests/noise/colored/test_white_noise.py +0 -0
  104. {samplepaths-0.1.0 → samplepaths-0.1.1}/tests/noise/test_fractional_gaussian_noise.py +0 -0
  105. {samplepaths-0.1.0 → samplepaths-0.1.1}/tests/noise/test_gaussian_noise.py +0 -0
  106. {samplepaths-0.1.0 → samplepaths-0.1.1}/tests/test_import.py +0 -0
  107. {samplepaths-0.1.0 → samplepaths-0.1.1}/tests/test_random.py +0 -0
  108. {samplepaths-0.1.0 → samplepaths-0.1.1}/tests/test_times.py +0 -0
  109. {samplepaths-0.1.0 → samplepaths-0.1.1}/tests/utils/__init__.py +0 -0
  110. {samplepaths-0.1.0 → samplepaths-0.1.1}/tests/utils/test_utils.py +0 -0
  111. {samplepaths-0.1.0 → samplepaths-0.1.1}/tests/utils/test_validation.py +0 -0
@@ -0,0 +1,204 @@
1
+ Metadata-Version: 2.5
2
+ Name: samplepaths
3
+ Version: 0.1.1
4
+ Summary: Generate realizations of stochastic processes
5
+ Project-URL: Homepage, https://github.com/samplepaths/samplepaths
6
+ Project-URL: Documentation, https://samplepaths.readthedocs.io/
7
+ Project-URL: Repository, https://github.com/samplepaths/samplepaths
8
+ Project-URL: Issues, https://github.com/samplepaths/samplepaths/issues
9
+ Project-URL: Author, https://girgis.me
10
+ Author-email: Bassem Girgis <brgirgis@gmail.com>, Christopher Flynn <crf204@gmail.com>
11
+ Maintainer-email: Bassem Girgis <brgirgis@gmail.com>
12
+ License-Expression: MIT
13
+ License-File: LICENSE
14
+ Keywords: monte carlo,processes,simulation,stochastic
15
+ Classifier: Development Status :: 4 - Beta
16
+ Classifier: Intended Audience :: Science/Research
17
+ Classifier: Natural Language :: English
18
+ Classifier: Operating System :: OS Independent
19
+ Classifier: Programming Language :: Python :: 3
20
+ Classifier: Programming Language :: Python :: 3.12
21
+ Classifier: Programming Language :: Python :: 3.13
22
+ Classifier: Programming Language :: Python :: 3.14
23
+ Classifier: Programming Language :: Python :: Implementation :: CPython
24
+ Classifier: Topic :: Scientific/Engineering
25
+ Classifier: Topic :: Scientific/Engineering :: Mathematics
26
+ Classifier: Topic :: Scientific/Engineering :: Physics
27
+ Classifier: Typing :: Typed
28
+ Requires-Python: >=3.12
29
+ Requires-Dist: numpy>=2.2.6
30
+ Requires-Dist: scipy>=1.15.3
31
+ Description-Content-Type: text/markdown
32
+
33
+ # samplepaths
34
+
35
+ [![Tests](https://github.com/samplepaths/samplepaths/actions/workflows/tests.yml/badge.svg)](https://github.com/samplepaths/samplepaths/actions/workflows/tests.yml)
36
+ [![Documentation](https://readthedocs.org/projects/samplepaths/badge/?version=latest)](https://samplepaths.readthedocs.io/)
37
+ [![PyPI version](https://img.shields.io/pypi/v/samplepaths)](https://pypi.org/project/samplepaths/)
38
+ [![Python versions](https://img.shields.io/pypi/pyversions/samplepaths)](https://pypi.org/project/samplepaths/)
39
+ [![Weekly downloads](https://img.shields.io/pypi/dw/samplepaths?label=downloads%2Fweek)](https://pypistats.org/packages/samplepaths)
40
+ [![Total downloads](https://img.shields.io/pepy/dt/samplepaths?label=total%20downloads)](https://pepy.tech/projects/samplepaths)
41
+ [![License](https://img.shields.io/pypi/l/samplepaths)](https://github.com/samplepaths/samplepaths/blob/master/LICENSE)
42
+
43
+ Generate realizations (sample paths) of stochastic processes as NumPy arrays.
44
+
45
+ ![Realizations of a Brownian motion with drift and their quantile bands](https://raw.githubusercontent.com/samplepaths/samplepaths/master/docs/_static/banner.png)
46
+
47
+ ```python
48
+ from samplepaths import BrownianMotion
49
+
50
+ bm = BrownianMotion(drift=1, scale=2, t=10)
51
+ path = bm.sample(1000) # 1001 values on [0, 10]
52
+ ```
53
+
54
+ - **37 processes** in four families: continuous-time, diffusion, discrete-time and noise
55
+ - **One interface**: every process is a class with a `sample(n)` method
56
+ - **Reproducible**: built on `numpy.random.Generator`, per process or through a seedable default
57
+ - **Typed**: type hints throughout, checked with mypy in strict mode
58
+ - **Light**: depends only on NumPy and SciPy
59
+
60
+ Full documentation: **https://samplepaths.readthedocs.io/**
61
+
62
+ ## Installation
63
+
64
+ ```shell
65
+ pip install samplepaths
66
+ ```
67
+
68
+ `samplepaths` requires Python 3.12 or newer, NumPy 2.2 or newer and SciPy 1.15 or newer.
69
+
70
+ ## Quickstart
71
+
72
+ Create a process with its parameters, then call `sample(n)` to generate a realization of `n` increments.
73
+ For a process on a time interval, the realization holds `n + 1` values and `times` holds the matching time values.
74
+
75
+ ```python
76
+ import matplotlib.pyplot as plt
77
+ from samplepaths import FractionalBrownianMotion
78
+
79
+ fbm = FractionalBrownianMotion(hurst=0.7, t=5)
80
+
81
+ for _ in range(3):
82
+ path = fbm.sample(512)
83
+ plt.plot(fbm.times, path)
84
+
85
+ plt.show()
86
+ ```
87
+
88
+ ### Reproducible results
89
+
90
+ Give a process its own generator, or seed the generator shared by all processes created without one.
91
+
92
+ ```python
93
+ import numpy as np
94
+ from samplepaths import BrownianMotion
95
+ from samplepaths import random
96
+
97
+ bm = BrownianMotion(rng=np.random.default_rng(42))
98
+
99
+ random.seed(value=42)
100
+ ```
101
+
102
+ ### Sampling at chosen times
103
+
104
+ Most continuous-time processes can be sampled at times of your choice with `sample_at()`.
105
+
106
+ ```python
107
+ from samplepaths import BrownianMotion
108
+
109
+ bm = BrownianMotion(drift=1, scale=1)
110
+ values = bm.sample_at([0, 3, 10, 11, 11.2, 20])
111
+ ```
112
+
113
+ ### More than one way to sample
114
+
115
+ `sample(n)` has the same signature on every process. Variants have their own methods.
116
+
117
+ ```python
118
+ from samplepaths import FractionalGaussianNoise
119
+ from samplepaths import GeometricBrownianMotion
120
+ from samplepaths import PoissonProcess
121
+
122
+ prices = GeometricBrownianMotion(drift=0.05, volatility=0.2).sample_with_initial(252, initial=100.0)
123
+ arrivals = PoissonProcess(rate=2.0).sample_with_length(10.0)
124
+ noise = FractionalGaussianNoise(hurst=0.6).sample_hosking(32)
125
+ ```
126
+
127
+ ### Generic simulation code
128
+
129
+ Because the interface is shared, simulation code does not depend on the process it simulates.
130
+
131
+ ```python
132
+ import numpy as np
133
+ from samplepaths import CoxIngersollRossProcess
134
+ from samplepaths import GeometricBrownianMotion
135
+ from samplepaths.base import BaseTimeProcess
136
+
137
+
138
+ def final_values(process: BaseTimeProcess, n: int, paths: int) -> np.ndarray:
139
+ """Simulate a number of paths and collect the last value of each."""
140
+ return np.array([process.sample(n)[-1] for _ in range(paths)])
141
+
142
+
143
+ final_values(GeometricBrownianMotion(drift=0.05, volatility=0.2), n=64, paths=1000)
144
+ final_values(CoxIngersollRossProcess(speed=1, mean=1, vol=0.5), n=64, paths=1000)
145
+ ```
146
+
147
+ ## Processes
148
+
149
+ ![One example process of each of the four families](https://raw.githubusercontent.com/samplepaths/samplepaths/master/docs/_static/families.png)
150
+
151
+ Every process can be imported from `samplepaths` or from the subpackage of its family.
152
+
153
+ | Family | Subpackage | Processes |
154
+ | --- | --- | --- |
155
+ | Continuous-time | `samplepaths.continuous` | `BesselProcess`, `BrownianBridge`, `BrownianExcursion`, `BrownianMeander`, `BrownianMotion`, `CauchyProcess`, `FractionalBrownianMotion`, `GammaProcess`, `GeometricBrownianMotion`, `InverseGaussianProcess`, `MixedPoissonProcess`, `MultifractionalBrownianMotion`, `PoissonProcess`, `SquaredBesselProcess`, `VarianceGammaProcess`, `WienerProcess` |
156
+ | Diffusion | `samplepaths.diffusion` | `DiffusionProcess`, `ConstantElasticityVarianceProcess`, `CoxIngersollRossProcess`, `ExtendedVasicekProcess`, `OrnsteinUhlenbeckProcess`, `VasicekProcess` |
157
+ | Discrete-time | `samplepaths.discrete` | `BernoulliProcess`, `ChineseRestaurantProcess`, `DirichletProcess`, `MarkovChain`, `MoranProcess`, `RandomWalk` |
158
+ | Noise | `samplepaths.noise` | `GaussianNoise`, `FractionalGaussianNoise`, `ColoredNoise`, `VioletNoise`, `BlueNoise`, `WhiteNoise`, `PinkNoise`, `RedNoise`, `BrownianNoise` |
159
+
160
+ Diffusion processes are approximated with the Euler-Maruyama method.
161
+
162
+ ## Documentation
163
+
164
+ The documentation at https://samplepaths.readthedocs.io/ contains:
165
+
166
+ - a [quickstart](https://samplepaths.readthedocs.io/en/latest/getting-started/quickstart.html)
167
+ - a user guide for [sampling](https://samplepaths.readthedocs.io/en/latest/guide/usage.html), [random number generation](https://samplepaths.readthedocs.io/en/latest/guide/random.html) and every family of processes
168
+ - an [API reference](https://samplepaths.readthedocs.io/en/latest/reference/index.html) for every class, method and function
169
+
170
+ ## Coming from stochastic
171
+
172
+ `samplepaths` is an independently maintained fork of [stochastic](https://github.com/crflynn/stochastic) 0.7.0 by Christopher Flynn.
173
+ It keeps the original processes and algorithms and modernizes everything around them: current Python, NumPy and SciPy, type hints, one sampling interface, and corrected drift handling.
174
+
175
+ Porting is mostly a change of import:
176
+
177
+ ```python
178
+ # stochastic
179
+ from stochastic.processes.continuous import BrownianMotion
180
+
181
+ # samplepaths
182
+ from samplepaths.continuous import BrownianMotion
183
+ ```
184
+
185
+ See the [migration guide](https://samplepaths.readthedocs.io/en/latest/project/migration.html) for the full list of changes.
186
+
187
+ ## Development
188
+
189
+ The project is managed with [uv](https://docs.astral.sh/uv/) and `make`.
190
+
191
+ ```shell
192
+ git clone https://github.com/samplepaths/samplepaths.git
193
+ cd samplepaths
194
+ make install # create the environment
195
+ make check # lint, type check, test and build the docs
196
+ ```
197
+
198
+ Run `make` to list all targets. Bug reports and pull requests are welcome on [GitHub](https://github.com/samplepaths/samplepaths/issues).
199
+
200
+ ## License
201
+
202
+ `samplepaths` is released under the [MIT license](https://github.com/samplepaths/samplepaths/blob/master/LICENSE).
203
+
204
+ It is maintained by [Bassem Girgis](https://girgis.me).
@@ -0,0 +1,172 @@
1
+ # samplepaths
2
+
3
+ [![Tests](https://github.com/samplepaths/samplepaths/actions/workflows/tests.yml/badge.svg)](https://github.com/samplepaths/samplepaths/actions/workflows/tests.yml)
4
+ [![Documentation](https://readthedocs.org/projects/samplepaths/badge/?version=latest)](https://samplepaths.readthedocs.io/)
5
+ [![PyPI version](https://img.shields.io/pypi/v/samplepaths)](https://pypi.org/project/samplepaths/)
6
+ [![Python versions](https://img.shields.io/pypi/pyversions/samplepaths)](https://pypi.org/project/samplepaths/)
7
+ [![Weekly downloads](https://img.shields.io/pypi/dw/samplepaths?label=downloads%2Fweek)](https://pypistats.org/packages/samplepaths)
8
+ [![Total downloads](https://img.shields.io/pepy/dt/samplepaths?label=total%20downloads)](https://pepy.tech/projects/samplepaths)
9
+ [![License](https://img.shields.io/pypi/l/samplepaths)](https://github.com/samplepaths/samplepaths/blob/master/LICENSE)
10
+
11
+ Generate realizations (sample paths) of stochastic processes as NumPy arrays.
12
+
13
+ ![Realizations of a Brownian motion with drift and their quantile bands](https://raw.githubusercontent.com/samplepaths/samplepaths/master/docs/_static/banner.png)
14
+
15
+ ```python
16
+ from samplepaths import BrownianMotion
17
+
18
+ bm = BrownianMotion(drift=1, scale=2, t=10)
19
+ path = bm.sample(1000) # 1001 values on [0, 10]
20
+ ```
21
+
22
+ - **37 processes** in four families: continuous-time, diffusion, discrete-time and noise
23
+ - **One interface**: every process is a class with a `sample(n)` method
24
+ - **Reproducible**: built on `numpy.random.Generator`, per process or through a seedable default
25
+ - **Typed**: type hints throughout, checked with mypy in strict mode
26
+ - **Light**: depends only on NumPy and SciPy
27
+
28
+ Full documentation: **https://samplepaths.readthedocs.io/**
29
+
30
+ ## Installation
31
+
32
+ ```shell
33
+ pip install samplepaths
34
+ ```
35
+
36
+ `samplepaths` requires Python 3.12 or newer, NumPy 2.2 or newer and SciPy 1.15 or newer.
37
+
38
+ ## Quickstart
39
+
40
+ Create a process with its parameters, then call `sample(n)` to generate a realization of `n` increments.
41
+ For a process on a time interval, the realization holds `n + 1` values and `times` holds the matching time values.
42
+
43
+ ```python
44
+ import matplotlib.pyplot as plt
45
+ from samplepaths import FractionalBrownianMotion
46
+
47
+ fbm = FractionalBrownianMotion(hurst=0.7, t=5)
48
+
49
+ for _ in range(3):
50
+ path = fbm.sample(512)
51
+ plt.plot(fbm.times, path)
52
+
53
+ plt.show()
54
+ ```
55
+
56
+ ### Reproducible results
57
+
58
+ Give a process its own generator, or seed the generator shared by all processes created without one.
59
+
60
+ ```python
61
+ import numpy as np
62
+ from samplepaths import BrownianMotion
63
+ from samplepaths import random
64
+
65
+ bm = BrownianMotion(rng=np.random.default_rng(42))
66
+
67
+ random.seed(value=42)
68
+ ```
69
+
70
+ ### Sampling at chosen times
71
+
72
+ Most continuous-time processes can be sampled at times of your choice with `sample_at()`.
73
+
74
+ ```python
75
+ from samplepaths import BrownianMotion
76
+
77
+ bm = BrownianMotion(drift=1, scale=1)
78
+ values = bm.sample_at([0, 3, 10, 11, 11.2, 20])
79
+ ```
80
+
81
+ ### More than one way to sample
82
+
83
+ `sample(n)` has the same signature on every process. Variants have their own methods.
84
+
85
+ ```python
86
+ from samplepaths import FractionalGaussianNoise
87
+ from samplepaths import GeometricBrownianMotion
88
+ from samplepaths import PoissonProcess
89
+
90
+ prices = GeometricBrownianMotion(drift=0.05, volatility=0.2).sample_with_initial(252, initial=100.0)
91
+ arrivals = PoissonProcess(rate=2.0).sample_with_length(10.0)
92
+ noise = FractionalGaussianNoise(hurst=0.6).sample_hosking(32)
93
+ ```
94
+
95
+ ### Generic simulation code
96
+
97
+ Because the interface is shared, simulation code does not depend on the process it simulates.
98
+
99
+ ```python
100
+ import numpy as np
101
+ from samplepaths import CoxIngersollRossProcess
102
+ from samplepaths import GeometricBrownianMotion
103
+ from samplepaths.base import BaseTimeProcess
104
+
105
+
106
+ def final_values(process: BaseTimeProcess, n: int, paths: int) -> np.ndarray:
107
+ """Simulate a number of paths and collect the last value of each."""
108
+ return np.array([process.sample(n)[-1] for _ in range(paths)])
109
+
110
+
111
+ final_values(GeometricBrownianMotion(drift=0.05, volatility=0.2), n=64, paths=1000)
112
+ final_values(CoxIngersollRossProcess(speed=1, mean=1, vol=0.5), n=64, paths=1000)
113
+ ```
114
+
115
+ ## Processes
116
+
117
+ ![One example process of each of the four families](https://raw.githubusercontent.com/samplepaths/samplepaths/master/docs/_static/families.png)
118
+
119
+ Every process can be imported from `samplepaths` or from the subpackage of its family.
120
+
121
+ | Family | Subpackage | Processes |
122
+ | --- | --- | --- |
123
+ | Continuous-time | `samplepaths.continuous` | `BesselProcess`, `BrownianBridge`, `BrownianExcursion`, `BrownianMeander`, `BrownianMotion`, `CauchyProcess`, `FractionalBrownianMotion`, `GammaProcess`, `GeometricBrownianMotion`, `InverseGaussianProcess`, `MixedPoissonProcess`, `MultifractionalBrownianMotion`, `PoissonProcess`, `SquaredBesselProcess`, `VarianceGammaProcess`, `WienerProcess` |
124
+ | Diffusion | `samplepaths.diffusion` | `DiffusionProcess`, `ConstantElasticityVarianceProcess`, `CoxIngersollRossProcess`, `ExtendedVasicekProcess`, `OrnsteinUhlenbeckProcess`, `VasicekProcess` |
125
+ | Discrete-time | `samplepaths.discrete` | `BernoulliProcess`, `ChineseRestaurantProcess`, `DirichletProcess`, `MarkovChain`, `MoranProcess`, `RandomWalk` |
126
+ | Noise | `samplepaths.noise` | `GaussianNoise`, `FractionalGaussianNoise`, `ColoredNoise`, `VioletNoise`, `BlueNoise`, `WhiteNoise`, `PinkNoise`, `RedNoise`, `BrownianNoise` |
127
+
128
+ Diffusion processes are approximated with the Euler-Maruyama method.
129
+
130
+ ## Documentation
131
+
132
+ The documentation at https://samplepaths.readthedocs.io/ contains:
133
+
134
+ - a [quickstart](https://samplepaths.readthedocs.io/en/latest/getting-started/quickstart.html)
135
+ - a user guide for [sampling](https://samplepaths.readthedocs.io/en/latest/guide/usage.html), [random number generation](https://samplepaths.readthedocs.io/en/latest/guide/random.html) and every family of processes
136
+ - an [API reference](https://samplepaths.readthedocs.io/en/latest/reference/index.html) for every class, method and function
137
+
138
+ ## Coming from stochastic
139
+
140
+ `samplepaths` is an independently maintained fork of [stochastic](https://github.com/crflynn/stochastic) 0.7.0 by Christopher Flynn.
141
+ It keeps the original processes and algorithms and modernizes everything around them: current Python, NumPy and SciPy, type hints, one sampling interface, and corrected drift handling.
142
+
143
+ Porting is mostly a change of import:
144
+
145
+ ```python
146
+ # stochastic
147
+ from stochastic.processes.continuous import BrownianMotion
148
+
149
+ # samplepaths
150
+ from samplepaths.continuous import BrownianMotion
151
+ ```
152
+
153
+ See the [migration guide](https://samplepaths.readthedocs.io/en/latest/project/migration.html) for the full list of changes.
154
+
155
+ ## Development
156
+
157
+ The project is managed with [uv](https://docs.astral.sh/uv/) and `make`.
158
+
159
+ ```shell
160
+ git clone https://github.com/samplepaths/samplepaths.git
161
+ cd samplepaths
162
+ make install # create the environment
163
+ make check # lint, type check, test and build the docs
164
+ ```
165
+
166
+ Run `make` to list all targets. Bug reports and pull requests are welcome on [GitHub](https://github.com/samplepaths/samplepaths/issues).
167
+
168
+ ## License
169
+
170
+ `samplepaths` is released under the [MIT license](https://github.com/samplepaths/samplepaths/blob/master/LICENSE).
171
+
172
+ It is maintained by [Bassem Girgis](https://girgis.me).
@@ -1,13 +1,13 @@
1
1
  [build-system]
2
- requires = ["hatchling"]
2
+ requires = ["hatchling", "hatch-vcs"]
3
3
  build-backend = "hatchling.build"
4
4
 
5
5
 
6
6
  [project]
7
7
  name = "samplepaths"
8
- version = "0.1.0"
8
+ dynamic = ["version"]
9
9
  description = "Generate realizations of stochastic processes"
10
- readme = "README.rst"
10
+ readme = "README.md"
11
11
  requires-python = ">=3.12"
12
12
  license = "MIT"
13
13
  license-files = ["LICENSE"]
@@ -67,8 +67,13 @@ dev = [
67
67
  ]
68
68
 
69
69
 
70
+ # The version is the git tag of the release, for example v0.2.0 gives 0.2.0.
71
+ [tool.hatch.version]
72
+ source = "vcs"
73
+
74
+
70
75
  [tool.hatch.build.targets.sdist]
71
- include = ["/src", "/tests", "/README.rst", "/LICENSE"]
76
+ include = ["/src", "/tests", "/README.md", "/LICENSE"]
72
77
 
73
78
 
74
79
  [tool.pytest.ini_options]
@@ -1,159 +0,0 @@
1
- Metadata-Version: 2.5
2
- Name: samplepaths
3
- Version: 0.1.0
4
- Summary: Generate realizations of stochastic processes
5
- Project-URL: Homepage, https://github.com/samplepaths/samplepaths
6
- Project-URL: Documentation, https://samplepaths.readthedocs.io/
7
- Project-URL: Repository, https://github.com/samplepaths/samplepaths
8
- Project-URL: Issues, https://github.com/samplepaths/samplepaths/issues
9
- Project-URL: Author, https://girgis.me
10
- Author-email: Bassem Girgis <brgirgis@gmail.com>, Christopher Flynn <crf204@gmail.com>
11
- Maintainer-email: Bassem Girgis <brgirgis@gmail.com>
12
- License-Expression: MIT
13
- License-File: LICENSE
14
- Keywords: monte carlo,processes,simulation,stochastic
15
- Classifier: Development Status :: 4 - Beta
16
- Classifier: Intended Audience :: Science/Research
17
- Classifier: Natural Language :: English
18
- Classifier: Operating System :: OS Independent
19
- Classifier: Programming Language :: Python :: 3
20
- Classifier: Programming Language :: Python :: 3.12
21
- Classifier: Programming Language :: Python :: 3.13
22
- Classifier: Programming Language :: Python :: 3.14
23
- Classifier: Programming Language :: Python :: Implementation :: CPython
24
- Classifier: Topic :: Scientific/Engineering
25
- Classifier: Topic :: Scientific/Engineering :: Mathematics
26
- Classifier: Topic :: Scientific/Engineering :: Physics
27
- Classifier: Typing :: Typed
28
- Requires-Python: >=3.12
29
- Requires-Dist: numpy>=2.2.6
30
- Requires-Dist: scipy>=1.15.3
31
- Description-Content-Type: text/x-rst
32
-
33
- samplepaths
34
- ============
35
-
36
- |tests| |docs| |pypi| |license|
37
-
38
- .. |tests| image:: https://github.com/samplepaths/samplepaths/actions/workflows/tests.yml/badge.svg
39
- :target: https://github.com/samplepaths/samplepaths/actions/workflows/tests.yml
40
-
41
- .. |docs| image:: https://readthedocs.org/projects/samplepaths/badge/?version=latest
42
- :target: https://samplepaths.readthedocs.io/
43
-
44
- .. |pypi| image:: https://img.shields.io/pypi/v/samplepaths.svg
45
- :target: https://pypi.org/project/samplepaths/
46
-
47
- .. |license| image:: https://img.shields.io/badge/license-MIT-blue.svg
48
- :target: https://github.com/samplepaths/samplepaths/blob/master/LICENSE
49
-
50
-
51
- A Python package for generating realizations of stochastic processes.
52
-
53
- ``samplepaths`` is an independently maintained fork of
54
- `stochastic <https://github.com/crflynn/stochastic>`_ by Christopher Flynn,
55
- modernized for current Python, ``numpy`` and ``scipy`` releases and shipped
56
- with type hints. It is maintained by `Bassem Girgis <https://girgis.me>`_.
57
-
58
- Installation
59
- ------------
60
-
61
- Install ``samplepaths`` from PyPI using pip
62
-
63
- .. code-block:: shell
64
-
65
- pip install samplepaths
66
-
67
- ``samplepaths`` requires Python 3.12 or newer.
68
-
69
- Dependencies
70
- ~~~~~~~~~~~~
71
-
72
- ``samplepaths`` uses ``numpy`` for many calculations and ``scipy`` for sampling
73
- specific random variables.
74
-
75
- Quickstart
76
- ----------
77
-
78
- Every process is a class with a ``sample(n)`` method which generates a
79
- realization as a ``numpy`` array.
80
-
81
- .. code-block:: python
82
-
83
- from samplepaths import BrownianMotion
84
-
85
- bm = BrownianMotion(drift=1, scale=2, t=10)
86
- path = bm.sample(1000) # 1001 values on [0, 10]
87
- times = bm.times # the matching time values
88
-
89
- Pass a ``numpy.random.Generator`` for reproducible results, or seed the
90
- generator shared by all processes:
91
-
92
- .. code-block:: python
93
-
94
- import numpy as np
95
- from samplepaths import BrownianMotion
96
- from samplepaths import random
97
-
98
- bm = BrownianMotion(rng=np.random.default_rng(42))
99
-
100
- random.seed(value=42)
101
-
102
- Some processes can be sampled at times of your choice, and some have
103
- additional sampling methods:
104
-
105
- .. code-block:: python
106
-
107
- from samplepaths import BrownianMotion
108
- from samplepaths import FractionalGaussianNoise
109
- from samplepaths import GeometricBrownianMotion
110
-
111
- values = BrownianMotion(drift=1).sample_at([0, 3, 10, 11, 11.2, 20])
112
- prices = GeometricBrownianMotion(drift=0.05, volatility=0.2).sample_with_initial(252, initial=100.0)
113
- noise = FractionalGaussianNoise(hurst=0.6).sample_hosking(32)
114
-
115
- Processes
116
- ---------
117
-
118
- All processes can be imported from ``samplepaths`` or from the subpackage of
119
- their family. Diffusion processes are approximated using the Euler-Maruyama
120
- method.
121
-
122
- * ``samplepaths.continuous``: BesselProcess, BrownianBridge,
123
- BrownianExcursion, BrownianMeander, BrownianMotion, CauchyProcess,
124
- FractionalBrownianMotion, GammaProcess, GeometricBrownianMotion,
125
- InverseGaussianProcess, MixedPoissonProcess,
126
- MultifractionalBrownianMotion, PoissonProcess, SquaredBesselProcess,
127
- VarianceGammaProcess, WienerProcess
128
- * ``samplepaths.diffusion``: DiffusionProcess (generalized),
129
- ConstantElasticityVarianceProcess, CoxIngersollRossProcess,
130
- ExtendedVasicekProcess, OrnsteinUhlenbeckProcess, VasicekProcess
131
- * ``samplepaths.discrete``: BernoulliProcess, ChineseRestaurantProcess,
132
- DirichletProcess, MarkovChain, MoranProcess, RandomWalk
133
- * ``samplepaths.noise``: BlueNoise, BrownianNoise, ColoredNoise,
134
- FractionalGaussianNoise, GaussianNoise, PinkNoise, RedNoise, VioletNoise,
135
- WhiteNoise
136
-
137
- Documentation
138
- -------------
139
-
140
- The documentation is at https://samplepaths.readthedocs.io/. It contains a
141
- user guide for every family of processes and an API reference.
142
-
143
- To build it locally, run ``make docs`` and open
144
- ``docs/_build/html/index.html``.
145
-
146
- Development
147
- -----------
148
-
149
- .. code-block:: shell
150
-
151
- make install # create the environment with uv
152
- make check # lint, type check, test and build the docs
153
-
154
- Run ``make`` to list all targets.
155
-
156
- License
157
- -------
158
-
159
- ``samplepaths`` is released under the MIT license. See the ``LICENSE`` file.
@@ -1,127 +0,0 @@
1
- samplepaths
2
- ============
3
-
4
- |tests| |docs| |pypi| |license|
5
-
6
- .. |tests| image:: https://github.com/samplepaths/samplepaths/actions/workflows/tests.yml/badge.svg
7
- :target: https://github.com/samplepaths/samplepaths/actions/workflows/tests.yml
8
-
9
- .. |docs| image:: https://readthedocs.org/projects/samplepaths/badge/?version=latest
10
- :target: https://samplepaths.readthedocs.io/
11
-
12
- .. |pypi| image:: https://img.shields.io/pypi/v/samplepaths.svg
13
- :target: https://pypi.org/project/samplepaths/
14
-
15
- .. |license| image:: https://img.shields.io/badge/license-MIT-blue.svg
16
- :target: https://github.com/samplepaths/samplepaths/blob/master/LICENSE
17
-
18
-
19
- A Python package for generating realizations of stochastic processes.
20
-
21
- ``samplepaths`` is an independently maintained fork of
22
- `stochastic <https://github.com/crflynn/stochastic>`_ by Christopher Flynn,
23
- modernized for current Python, ``numpy`` and ``scipy`` releases and shipped
24
- with type hints. It is maintained by `Bassem Girgis <https://girgis.me>`_.
25
-
26
- Installation
27
- ------------
28
-
29
- Install ``samplepaths`` from PyPI using pip
30
-
31
- .. code-block:: shell
32
-
33
- pip install samplepaths
34
-
35
- ``samplepaths`` requires Python 3.12 or newer.
36
-
37
- Dependencies
38
- ~~~~~~~~~~~~
39
-
40
- ``samplepaths`` uses ``numpy`` for many calculations and ``scipy`` for sampling
41
- specific random variables.
42
-
43
- Quickstart
44
- ----------
45
-
46
- Every process is a class with a ``sample(n)`` method which generates a
47
- realization as a ``numpy`` array.
48
-
49
- .. code-block:: python
50
-
51
- from samplepaths import BrownianMotion
52
-
53
- bm = BrownianMotion(drift=1, scale=2, t=10)
54
- path = bm.sample(1000) # 1001 values on [0, 10]
55
- times = bm.times # the matching time values
56
-
57
- Pass a ``numpy.random.Generator`` for reproducible results, or seed the
58
- generator shared by all processes:
59
-
60
- .. code-block:: python
61
-
62
- import numpy as np
63
- from samplepaths import BrownianMotion
64
- from samplepaths import random
65
-
66
- bm = BrownianMotion(rng=np.random.default_rng(42))
67
-
68
- random.seed(value=42)
69
-
70
- Some processes can be sampled at times of your choice, and some have
71
- additional sampling methods:
72
-
73
- .. code-block:: python
74
-
75
- from samplepaths import BrownianMotion
76
- from samplepaths import FractionalGaussianNoise
77
- from samplepaths import GeometricBrownianMotion
78
-
79
- values = BrownianMotion(drift=1).sample_at([0, 3, 10, 11, 11.2, 20])
80
- prices = GeometricBrownianMotion(drift=0.05, volatility=0.2).sample_with_initial(252, initial=100.0)
81
- noise = FractionalGaussianNoise(hurst=0.6).sample_hosking(32)
82
-
83
- Processes
84
- ---------
85
-
86
- All processes can be imported from ``samplepaths`` or from the subpackage of
87
- their family. Diffusion processes are approximated using the Euler-Maruyama
88
- method.
89
-
90
- * ``samplepaths.continuous``: BesselProcess, BrownianBridge,
91
- BrownianExcursion, BrownianMeander, BrownianMotion, CauchyProcess,
92
- FractionalBrownianMotion, GammaProcess, GeometricBrownianMotion,
93
- InverseGaussianProcess, MixedPoissonProcess,
94
- MultifractionalBrownianMotion, PoissonProcess, SquaredBesselProcess,
95
- VarianceGammaProcess, WienerProcess
96
- * ``samplepaths.diffusion``: DiffusionProcess (generalized),
97
- ConstantElasticityVarianceProcess, CoxIngersollRossProcess,
98
- ExtendedVasicekProcess, OrnsteinUhlenbeckProcess, VasicekProcess
99
- * ``samplepaths.discrete``: BernoulliProcess, ChineseRestaurantProcess,
100
- DirichletProcess, MarkovChain, MoranProcess, RandomWalk
101
- * ``samplepaths.noise``: BlueNoise, BrownianNoise, ColoredNoise,
102
- FractionalGaussianNoise, GaussianNoise, PinkNoise, RedNoise, VioletNoise,
103
- WhiteNoise
104
-
105
- Documentation
106
- -------------
107
-
108
- The documentation is at https://samplepaths.readthedocs.io/. It contains a
109
- user guide for every family of processes and an API reference.
110
-
111
- To build it locally, run ``make docs`` and open
112
- ``docs/_build/html/index.html``.
113
-
114
- Development
115
- -----------
116
-
117
- .. code-block:: shell
118
-
119
- make install # create the environment with uv
120
- make check # lint, type check, test and build the docs
121
-
122
- Run ``make`` to list all targets.
123
-
124
- License
125
- -------
126
-
127
- ``samplepaths`` is released under the MIT license. See the ``LICENSE`` file.
File without changes
File without changes