Skip to main content

samplepaths

tests docs pypi license

A Python package for generating realizations of stochastic processes.

samplepaths is an independently maintained fork of stochastic by Christopher Flynn, modernized for current Python, numpy and scipy releases and shipped with type hints. It is maintained by Bassem Girgis.

Installation

Install samplepaths from PyPI using pip

pip install samplepaths

samplepaths requires Python 3.12 or newer.

Dependencies

samplepaths uses numpy for many calculations and scipy for sampling specific random variables.

Quickstart

Every process is a class with a sample(n) method which generates a realization as a numpy array.

from samplepaths import BrownianMotion

bm = BrownianMotion(drift=1, scale=2, t=10)
path = bm.sample(1000)  # 1001 values on [0, 10]
times = bm.times  # the matching time values

Pass a numpy.random.Generator for reproducible results, or seed the generator shared by all processes:

import numpy as np
from samplepaths import BrownianMotion
from samplepaths import random

bm = BrownianMotion(rng=np.random.default_rng(42))

random.seed(value=42)

Some processes can be sampled at times of your choice, and some have additional sampling methods:

from samplepaths import BrownianMotion
from samplepaths import FractionalGaussianNoise
from samplepaths import GeometricBrownianMotion

values = BrownianMotion(drift=1).sample_at([0, 3, 10, 11, 11.2, 20])
prices = GeometricBrownianMotion(drift=0.05, volatility=0.2).sample_with_initial(252, initial=100.0)
noise = FractionalGaussianNoise(hurst=0.6).sample_hosking(32)

Processes

All processes can be imported from samplepaths or from the subpackage of their family. Diffusion processes are approximated using the Euler-Maruyama method.

  • samplepaths.continuous: BesselProcess, BrownianBridge, BrownianExcursion, BrownianMeander, BrownianMotion, CauchyProcess, FractionalBrownianMotion, GammaProcess, GeometricBrownianMotion, InverseGaussianProcess, MixedPoissonProcess, MultifractionalBrownianMotion, PoissonProcess, SquaredBesselProcess, VarianceGammaProcess, WienerProcess

  • samplepaths.diffusion: DiffusionProcess (generalized), ConstantElasticityVarianceProcess, CoxIngersollRossProcess, ExtendedVasicekProcess, OrnsteinUhlenbeckProcess, VasicekProcess

  • samplepaths.discrete: BernoulliProcess, ChineseRestaurantProcess, DirichletProcess, MarkovChain, MoranProcess, RandomWalk

  • samplepaths.noise: BlueNoise, BrownianNoise, ColoredNoise, FractionalGaussianNoise, GaussianNoise, PinkNoise, RedNoise, VioletNoise, WhiteNoise

Documentation

The documentation is at https://samplepaths.readthedocs.io/. It contains a user guide for every family of processes and an API reference.

To build it locally, run make docs and open docs/_build/html/index.html.

Development

make install  # create the environment with uv
make check    # lint, type check, test and build the docs

Run make to list all targets.

License

samplepaths is released under the MIT license. See the LICENSE file.

Metadata

Release files for samplepaths 0.1.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for samplepaths 0.1.0
File Size Uploaded Provenance Actions
samplepaths-0.1.0.tar.gz 39.6 kB Without provenance Details for samplepaths-0.1.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for samplepaths 0.1.0
File Interpreter ABI Platform Actions
samplepaths-0.1.0-py3-none-any.whl Python 3 none any Details for samplepaths-0.1.0-py3-none-any.whl

Total release size: 96.1 kB

Release files / samplepaths-0.1.0.tar.gz

Download URL samplepaths-0.1.0.tar.gz
Size 39.6 kB
Tags Source
SHA-256 checksum
How to use checksums
6230df361402af249da57ed6b5a024e24a04db810aadbb3552d373aea5ea7637
BLAKE2b-256 checksum
How to use checksums
db0d22fde7f7b1994899d658ed918c07c027b427148109dfeb3a8bb88abe2cf1
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via uv/0.13.10 {"installer":{"name":"uv","version":"0.13.10","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"26.04","id":"resolute","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

Release files / samplepaths-0.1.0-py3-none-any.whl

Download URL samplepaths-0.1.0-py3-none-any.whl
Size 56.5 kB
Tags Python 3
SHA-256 checksum
How to use checksums
60462d2185388b2d95bd96f87ff05ac75ad03a4cbb16f8fc739817400df5afbb
BLAKE2b-256 checksum
How to use checksums
2e90ac78cf9c819d1a86ffded32d831e3c9f41d8ff99f38cf8423954dd8bbed9
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via uv/0.13.10 {"installer":{"name":"uv","version":"0.13.10","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"26.04","id":"resolute","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

Security for samplepaths 0.1.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page