samplepaths 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 (109) hide show
  1. samplepaths-0.1.0/.gitignore +146 -0
  2. samplepaths-0.1.0/LICENSE +22 -0
  3. samplepaths-0.1.0/PKG-INFO +159 -0
  4. samplepaths-0.1.0/README.rst +127 -0
  5. samplepaths-0.1.0/pyproject.toml +115 -0
  6. samplepaths-0.1.0/src/samplepaths/__init__.py +96 -0
  7. samplepaths-0.1.0/src/samplepaths/base/__init__.py +11 -0
  8. samplepaths-0.1.0/src/samplepaths/base/base_process.py +52 -0
  9. samplepaths-0.1.0/src/samplepaths/base/base_sequence_process.py +10 -0
  10. samplepaths-0.1.0/src/samplepaths/base/base_time_process.py +124 -0
  11. samplepaths-0.1.0/src/samplepaths/continuous/__init__.py +37 -0
  12. samplepaths-0.1.0/src/samplepaths/continuous/bessel_process.py +87 -0
  13. samplepaths-0.1.0/src/samplepaths/continuous/brownian_bridge.py +93 -0
  14. samplepaths-0.1.0/src/samplepaths/continuous/brownian_excursion.py +99 -0
  15. samplepaths-0.1.0/src/samplepaths/continuous/brownian_meander.py +148 -0
  16. samplepaths-0.1.0/src/samplepaths/continuous/brownian_motion.py +116 -0
  17. samplepaths-0.1.0/src/samplepaths/continuous/cauchy_process.py +106 -0
  18. samplepaths-0.1.0/src/samplepaths/continuous/fractional_brownian_motion.py +58 -0
  19. samplepaths-0.1.0/src/samplepaths/continuous/gamma_process.py +162 -0
  20. samplepaths-0.1.0/src/samplepaths/continuous/geometric_brownian_motion.py +166 -0
  21. samplepaths-0.1.0/src/samplepaths/continuous/inverse_gaussian_process.py +193 -0
  22. samplepaths-0.1.0/src/samplepaths/continuous/mixed_poisson_process.py +114 -0
  23. samplepaths-0.1.0/src/samplepaths/continuous/multifractional_brownian_motion.py +128 -0
  24. samplepaths-0.1.0/src/samplepaths/continuous/poisson_process.py +114 -0
  25. samplepaths-0.1.0/src/samplepaths/continuous/squared_bessel_process.py +61 -0
  26. samplepaths-0.1.0/src/samplepaths/continuous/variance_gamma_process.py +156 -0
  27. samplepaths-0.1.0/src/samplepaths/continuous/wiener_process.py +36 -0
  28. samplepaths-0.1.0/src/samplepaths/diffusion/__init__.py +17 -0
  29. samplepaths-0.1.0/src/samplepaths/diffusion/constant_elasticity_variance_process.py +81 -0
  30. samplepaths-0.1.0/src/samplepaths/diffusion/cox_ingersoll_ross_process.py +70 -0
  31. samplepaths-0.1.0/src/samplepaths/diffusion/diffusion_process.py +175 -0
  32. samplepaths-0.1.0/src/samplepaths/diffusion/extended_vasicek_process.py +72 -0
  33. samplepaths-0.1.0/src/samplepaths/diffusion/ornstein_uhlenbeck_process.py +61 -0
  34. samplepaths-0.1.0/src/samplepaths/diffusion/vasicek_process.py +66 -0
  35. samplepaths-0.1.0/src/samplepaths/discrete/__init__.py +17 -0
  36. samplepaths-0.1.0/src/samplepaths/discrete/bernoulli_process.py +78 -0
  37. samplepaths-0.1.0/src/samplepaths/discrete/chinese_restaurant_process.py +194 -0
  38. samplepaths-0.1.0/src/samplepaths/discrete/dirichlet_process.py +97 -0
  39. samplepaths-0.1.0/src/samplepaths/discrete/markov_chain.py +131 -0
  40. samplepaths-0.1.0/src/samplepaths/discrete/moran_process.py +122 -0
  41. samplepaths-0.1.0/src/samplepaths/discrete/random_walk.py +115 -0
  42. samplepaths-0.1.0/src/samplepaths/noise/__init__.py +25 -0
  43. samplepaths-0.1.0/src/samplepaths/noise/colored/__init__.py +19 -0
  44. samplepaths-0.1.0/src/samplepaths/noise/colored/blue_noise.py +32 -0
  45. samplepaths-0.1.0/src/samplepaths/noise/colored/brownian_noise.py +18 -0
  46. samplepaths-0.1.0/src/samplepaths/noise/colored/colored_noise.py +120 -0
  47. samplepaths-0.1.0/src/samplepaths/noise/colored/pink_noise.py +32 -0
  48. samplepaths-0.1.0/src/samplepaths/noise/colored/red_noise.py +32 -0
  49. samplepaths-0.1.0/src/samplepaths/noise/colored/violet_noise.py +32 -0
  50. samplepaths-0.1.0/src/samplepaths/noise/colored/white_noise.py +32 -0
  51. samplepaths-0.1.0/src/samplepaths/noise/fractional_gaussian_noise.py +219 -0
  52. samplepaths-0.1.0/src/samplepaths/noise/gaussian_noise.py +78 -0
  53. samplepaths-0.1.0/src/samplepaths/py.typed +0 -0
  54. samplepaths-0.1.0/src/samplepaths/random.py +50 -0
  55. samplepaths-0.1.0/src/samplepaths/utils/__init__.py +48 -0
  56. samplepaths-0.1.0/src/samplepaths/utils/validation.py +176 -0
  57. samplepaths-0.1.0/tests/__init__.py +0 -0
  58. samplepaths-0.1.0/tests/base/__init__.py +0 -0
  59. samplepaths-0.1.0/tests/base/test_base_process.py +47 -0
  60. samplepaths-0.1.0/tests/base/test_base_sequence_process.py +8 -0
  61. samplepaths-0.1.0/tests/base/test_base_time_process.py +144 -0
  62. samplepaths-0.1.0/tests/continuous/__init__.py +0 -0
  63. samplepaths-0.1.0/tests/continuous/test_bessel_process.py +86 -0
  64. samplepaths-0.1.0/tests/continuous/test_brownian_bridge.py +114 -0
  65. samplepaths-0.1.0/tests/continuous/test_brownian_excursion.py +84 -0
  66. samplepaths-0.1.0/tests/continuous/test_brownian_meander.py +84 -0
  67. samplepaths-0.1.0/tests/continuous/test_brownian_motion.py +203 -0
  68. samplepaths-0.1.0/tests/continuous/test_cauchy_process.py +52 -0
  69. samplepaths-0.1.0/tests/continuous/test_fractional_brownian_motion.py +62 -0
  70. samplepaths-0.1.0/tests/continuous/test_gamma_process.py +127 -0
  71. samplepaths-0.1.0/tests/continuous/test_geometric_brownian_motion.py +154 -0
  72. samplepaths-0.1.0/tests/continuous/test_inverse_gaussian_process.py +189 -0
  73. samplepaths-0.1.0/tests/continuous/test_mixed_poisson_process.py +154 -0
  74. samplepaths-0.1.0/tests/continuous/test_multifractional_brownian_motion.py +81 -0
  75. samplepaths-0.1.0/tests/continuous/test_poisson_process.py +114 -0
  76. samplepaths-0.1.0/tests/continuous/test_squared_bessel_process.py +46 -0
  77. samplepaths-0.1.0/tests/continuous/test_variance_gamma_process.py +184 -0
  78. samplepaths-0.1.0/tests/continuous/test_wiener_process.py +14 -0
  79. samplepaths-0.1.0/tests/diffusion/__init__.py +0 -0
  80. samplepaths-0.1.0/tests/diffusion/test_constant_elasticity_variance_process.py +10 -0
  81. samplepaths-0.1.0/tests/diffusion/test_cox_ingersoll_ross_process.py +8 -0
  82. samplepaths-0.1.0/tests/diffusion/test_diffusion_process.py +95 -0
  83. samplepaths-0.1.0/tests/diffusion/test_extended_vasicek_process.py +8 -0
  84. samplepaths-0.1.0/tests/diffusion/test_ornstein_uhlenbeck_process.py +8 -0
  85. samplepaths-0.1.0/tests/diffusion/test_vasicek_process.py +8 -0
  86. samplepaths-0.1.0/tests/discrete/__init__.py +0 -0
  87. samplepaths-0.1.0/tests/discrete/test_bernoulli_process.py +77 -0
  88. samplepaths-0.1.0/tests/discrete/test_chinese_restaurant_process.py +237 -0
  89. samplepaths-0.1.0/tests/discrete/test_dirichlet_process.py +96 -0
  90. samplepaths-0.1.0/tests/discrete/test_markov_chain.py +142 -0
  91. samplepaths-0.1.0/tests/discrete/test_moran_process.py +87 -0
  92. samplepaths-0.1.0/tests/discrete/test_random_walk.py +120 -0
  93. samplepaths-0.1.0/tests/noise/__init__.py +0 -0
  94. samplepaths-0.1.0/tests/noise/colored/__init__.py +0 -0
  95. samplepaths-0.1.0/tests/noise/colored/test_blue_noise.py +46 -0
  96. samplepaths-0.1.0/tests/noise/colored/test_brownian_noise.py +46 -0
  97. samplepaths-0.1.0/tests/noise/colored/test_colored_noise.py +68 -0
  98. samplepaths-0.1.0/tests/noise/colored/test_pink_noise.py +46 -0
  99. samplepaths-0.1.0/tests/noise/colored/test_red_noise.py +46 -0
  100. samplepaths-0.1.0/tests/noise/colored/test_violet_noise.py +46 -0
  101. samplepaths-0.1.0/tests/noise/colored/test_white_noise.py +46 -0
  102. samplepaths-0.1.0/tests/noise/test_fractional_gaussian_noise.py +157 -0
  103. samplepaths-0.1.0/tests/noise/test_gaussian_noise.py +77 -0
  104. samplepaths-0.1.0/tests/test_import.py +43 -0
  105. samplepaths-0.1.0/tests/test_random.py +29 -0
  106. samplepaths-0.1.0/tests/test_times.py +83 -0
  107. samplepaths-0.1.0/tests/utils/__init__.py +0 -0
  108. samplepaths-0.1.0/tests/utils/test_utils.py +42 -0
  109. samplepaths-0.1.0/tests/utils/test_validation.py +237 -0
@@ -0,0 +1,146 @@
1
+ # Byte-compiled / optimized / DLL files
2
+ __pycache__/
3
+ *.py[cod]
4
+ *$py.class
5
+
6
+ # C extensions
7
+ *.so
8
+
9
+ # Distribution / packaging
10
+ .Python
11
+ build/
12
+ develop-eggs/
13
+ dist/
14
+ downloads/
15
+ eggs/
16
+ .eggs/
17
+ lib/
18
+ lib64/
19
+ parts/
20
+ sdist/
21
+ var/
22
+ wheels/
23
+ share/python-wheels/
24
+ *.egg-info/
25
+ .installed.cfg
26
+ *.egg
27
+ MANIFEST
28
+
29
+ # PyInstaller
30
+ # Usually these files are written by a python script from a template
31
+ # before PyInstaller builds the exe, so as to inject date/other infos into it.
32
+ *.manifest
33
+ *.spec
34
+
35
+ # Installer logs
36
+ pip-log.txt
37
+ pip-delete-this-directory.txt
38
+
39
+ # Unit test / coverage reports
40
+ htmlcov/
41
+ .tox/
42
+ .nox/
43
+ .coverage
44
+ .coverage.*
45
+ .cache
46
+ nosetests.xml
47
+ coverage.xml
48
+ *.cover
49
+ *.py,cover
50
+ .hypothesis/
51
+ .pytest_cache/
52
+ cover/
53
+
54
+ # Translations
55
+ *.mo
56
+ *.pot
57
+
58
+ # Django stuff:
59
+ *.log
60
+ local_settings.py
61
+ db.sqlite3
62
+ db.sqlite3-journal
63
+
64
+ # Flask stuff:
65
+ instance/
66
+ .webassets-cache
67
+
68
+ # Scrapy stuff:
69
+ .scrapy
70
+
71
+ # Sphinx documentation
72
+ docs/_build/
73
+
74
+ # PyBuilder
75
+ .pybuilder/
76
+ target/
77
+
78
+ # Jupyter Notebook
79
+ .ipynb_checkpoints
80
+
81
+ # IPython
82
+ profile_default/
83
+ ipython_config.py
84
+
85
+ # pyenv
86
+ # For a library or package, you might want to ignore these files since the code is
87
+ # intended to run in multiple environments; otherwise, check them in:
88
+ # .python-version
89
+
90
+ # pipenv
91
+ # According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.
92
+ # However, in case of collaboration, if having platform-specific dependencies or dependencies
93
+ # having no cross-platform support, pipenv may install dependencies that don't work, or not
94
+ # install all needed dependencies.
95
+ #Pipfile.lock
96
+
97
+ # PEP 582; used by e.g. github.com/David-OConnor/pyflow
98
+ __pypackages__/
99
+
100
+ # Celery stuff
101
+ celerybeat-schedule
102
+ celerybeat.pid
103
+
104
+ # SageMath parsed files
105
+ *.sage.py
106
+
107
+ # Environments
108
+ .env
109
+ .venv
110
+ env/
111
+ venv/
112
+ ENV/
113
+ env.bak/
114
+ venv.bak/
115
+
116
+ # Spyder project settings
117
+ .spyderproject
118
+ .spyproject
119
+
120
+ # Rope project settings
121
+ .ropeproject
122
+
123
+ # mkdocs documentation
124
+ /site
125
+
126
+ # mypy
127
+ .mypy_cache/
128
+ .dmypy.json
129
+ dmypy.json
130
+
131
+ # Pyre type checker
132
+ .pyre/
133
+
134
+ # pytype static type analyzer
135
+ .pytype/
136
+
137
+ # Cython debug symbols
138
+ cython_debug/
139
+
140
+ # mac
141
+ .DS_Store
142
+
143
+ # intellij
144
+ .idea/
145
+ # Generated API reference
146
+ docs/reference/api/
@@ -0,0 +1,22 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2018-2020 Christopher Flynn
4
+ Copyright (c) 2026 Bassem Girgis
5
+
6
+ Permission is hereby granted, free of charge, to any person obtaining a copy
7
+ of this software and associated documentation files (the "Software"), to deal
8
+ in the Software without restriction, including without limitation the rights
9
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10
+ copies of the Software, and to permit persons to whom the Software is
11
+ furnished to do so, subject to the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be included in all
14
+ copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22
+ SOFTWARE.
@@ -0,0 +1,159 @@
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.
@@ -0,0 +1,127 @@
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.
@@ -0,0 +1,115 @@
1
+ [build-system]
2
+ requires = ["hatchling"]
3
+ build-backend = "hatchling.build"
4
+
5
+
6
+ [project]
7
+ name = "samplepaths"
8
+ version = "0.1.0"
9
+ description = "Generate realizations of stochastic processes"
10
+ readme = "README.rst"
11
+ requires-python = ">=3.12"
12
+ license = "MIT"
13
+ license-files = ["LICENSE"]
14
+ authors = [
15
+ { name = "Bassem Girgis", email = "brgirgis@gmail.com" },
16
+ { name = "Christopher Flynn", email = "crf204@gmail.com" },
17
+ ]
18
+ maintainers = [{ name = "Bassem Girgis", email = "brgirgis@gmail.com" }]
19
+ keywords = ["stochastic", "processes", "simulation", "monte carlo"]
20
+ classifiers = [
21
+ "Development Status :: 4 - Beta",
22
+ "Intended Audience :: Science/Research",
23
+ "Natural Language :: English",
24
+ "Operating System :: OS Independent",
25
+ "Programming Language :: Python :: 3",
26
+ "Programming Language :: Python :: 3.12",
27
+ "Programming Language :: Python :: 3.13",
28
+ "Programming Language :: Python :: 3.14",
29
+ "Programming Language :: Python :: Implementation :: CPython",
30
+ "Topic :: Scientific/Engineering",
31
+ "Topic :: Scientific/Engineering :: Mathematics",
32
+ "Topic :: Scientific/Engineering :: Physics",
33
+ "Typing :: Typed",
34
+ ]
35
+ dependencies = ["numpy>=2.2.6", "scipy>=1.15.3"]
36
+
37
+
38
+ [project.urls]
39
+ Homepage = "https://github.com/samplepaths/samplepaths"
40
+ Documentation = "https://samplepaths.readthedocs.io/"
41
+ Repository = "https://github.com/samplepaths/samplepaths"
42
+ Issues = "https://github.com/samplepaths/samplepaths/issues"
43
+ Author = "https://girgis.me"
44
+
45
+
46
+ [dependency-groups]
47
+ test = ["pytest>=9.0.2", "pytest-cov>=7.0.0", "pytest-xdist>=3.8.0"]
48
+ lint = ["mypy>=1.19.1", "ruff>=0.14.0", "scipy-stubs>=1.15.3.0"]
49
+ docs = [
50
+ "matplotlib>=3.10.8",
51
+ "sphinx>=8.1.3",
52
+ "sphinx-autobuild>=2024.10.3",
53
+ "furo>=2025.9.25",
54
+ ]
55
+ # The notebooks compare samplepaths against the original stochastic package.
56
+ notebooks = [
57
+ "ipykernel>=7.1.0",
58
+ "nbformat>=5.10.4",
59
+ "plotly>=6.5.2",
60
+ "stochastic>=0.4.0",
61
+ ]
62
+ dev = [
63
+ { include-group = "test" },
64
+ { include-group = "lint" },
65
+ { include-group = "docs" },
66
+ { include-group = "notebooks" },
67
+ ]
68
+
69
+
70
+ [tool.hatch.build.targets.sdist]
71
+ include = ["/src", "/tests", "/README.rst", "/LICENSE"]
72
+
73
+
74
+ [tool.pytest.ini_options]
75
+ testpaths = ["tests"]
76
+
77
+
78
+ [tool.coverage.run]
79
+ source = ["samplepaths"]
80
+
81
+
82
+ [tool.ruff]
83
+ line-length = 100
84
+ src = ["src", "tests"]
85
+
86
+ [tool.ruff.lint]
87
+ select = [
88
+ "E", # pycodestyle errors
89
+ "W", # pycodestyle warnings
90
+ "F", # pyflakes
91
+ "I", # isort
92
+ "B", # flake8-bugbear
93
+ "UP", # pyupgrade
94
+ "T20", # flake8-print
95
+ "D", # pydocstyle
96
+ ]
97
+ ignore = [
98
+ "D105", # magic methods need no docstring
99
+ "D107", # constructor parameters are documented in the class docstring
100
+ ]
101
+
102
+ [tool.ruff.lint.pydocstyle]
103
+ convention = "pep257"
104
+
105
+ [tool.ruff.lint.per-file-ignores]
106
+ "tests/**" = ["D"]
107
+ "docs/conf.py" = ["D"]
108
+ "docs/scripts/make_images.py" = ["T20"]
109
+
110
+
111
+ [tool.mypy]
112
+ strict = true
113
+ warn_unreachable = true
114
+ disallow_any_unimported = true
115
+ show_error_codes = true
@@ -0,0 +1,96 @@
1
+ """Generate realizations of stochastic processes."""
2
+
3
+ from importlib.metadata import version
4
+
5
+ from .continuous import (
6
+ BesselProcess,
7
+ BrownianBridge,
8
+ BrownianExcursion,
9
+ BrownianMeander,
10
+ BrownianMotion,
11
+ CauchyProcess,
12
+ FractionalBrownianMotion,
13
+ GammaProcess,
14
+ GeometricBrownianMotion,
15
+ InverseGaussianProcess,
16
+ MixedPoissonProcess,
17
+ MultifractionalBrownianMotion,
18
+ PoissonProcess,
19
+ SquaredBesselProcess,
20
+ VarianceGammaProcess,
21
+ WienerProcess,
22
+ )
23
+ from .diffusion import (
24
+ ConstantElasticityVarianceProcess,
25
+ CoxIngersollRossProcess,
26
+ DiffusionProcess,
27
+ ExtendedVasicekProcess,
28
+ OrnsteinUhlenbeckProcess,
29
+ VasicekProcess,
30
+ )
31
+ from .discrete import (
32
+ BernoulliProcess,
33
+ ChineseRestaurantProcess,
34
+ DirichletProcess,
35
+ MarkovChain,
36
+ MoranProcess,
37
+ RandomWalk,
38
+ )
39
+ from .noise import (
40
+ BlueNoise,
41
+ BrownianNoise,
42
+ ColoredNoise,
43
+ FractionalGaussianNoise,
44
+ GaussianNoise,
45
+ PinkNoise,
46
+ RedNoise,
47
+ VioletNoise,
48
+ WhiteNoise,
49
+ )
50
+
51
+ __version__ = version("samplepaths")
52
+
53
+ __all__ = [
54
+ "__version__",
55
+ # continuous
56
+ "BesselProcess",
57
+ "BrownianBridge",
58
+ "BrownianExcursion",
59
+ "BrownianMeander",
60
+ "BrownianMotion",
61
+ "CauchyProcess",
62
+ "FractionalBrownianMotion",
63
+ "GammaProcess",
64
+ "GeometricBrownianMotion",
65
+ "InverseGaussianProcess",
66
+ "MixedPoissonProcess",
67
+ "MultifractionalBrownianMotion",
68
+ "PoissonProcess",
69
+ "SquaredBesselProcess",
70
+ "VarianceGammaProcess",
71
+ "WienerProcess",
72
+ # diffusion
73
+ "ConstantElasticityVarianceProcess",
74
+ "CoxIngersollRossProcess",
75
+ "DiffusionProcess",
76
+ "ExtendedVasicekProcess",
77
+ "OrnsteinUhlenbeckProcess",
78
+ "VasicekProcess",
79
+ # discrete
80
+ "BernoulliProcess",
81
+ "ChineseRestaurantProcess",
82
+ "DirichletProcess",
83
+ "MarkovChain",
84
+ "MoranProcess",
85
+ "RandomWalk",
86
+ # noise
87
+ "BlueNoise",
88
+ "BrownianNoise",
89
+ "ColoredNoise",
90
+ "FractionalGaussianNoise",
91
+ "GaussianNoise",
92
+ "PinkNoise",
93
+ "RedNoise",
94
+ "VioletNoise",
95
+ "WhiteNoise",
96
+ ]
@@ -0,0 +1,11 @@
1
+ """Base classes of the processes."""
2
+
3
+ from .base_process import BaseProcess
4
+ from .base_sequence_process import BaseSequenceProcess
5
+ from .base_time_process import BaseTimeProcess
6
+
7
+ __all__ = [
8
+ "BaseProcess",
9
+ "BaseSequenceProcess",
10
+ "BaseTimeProcess",
11
+ ]