Skip to main content

A library for random number/stochastic process simulation with high performance.

Project description

DiffusionX

English | 简体中文

PyPI PyPI - License

[!NOTE] Development is in progress.

The Python binding of the same-named Rust crate diffusionx, a multi-threaded Rust crate for random number generation and stochastic process simulation, via PyO3.

Usage

Random Number Generation

High-performance parallel random number generation using diffusionx.random.

from diffusionx import random

# Generate standard normal random numbers (10 samples)
x = random.randn(10)

# Generate uniform random numbers (3x3 matrix) in [0, 1)
u = random.uniform((3, 3), low=0.0, high=1.0)

# Generate alpha-stable random numbers (alpha=1.5, beta=0.5)
s = random.stable_rand(alpha=1.5, beta=0.5, size=1000)

Stochastic Process Simulation

Simulate various stochastic processes and calculate functionals using diffusionx.simulation.

from diffusionx.simulation import Bm, FBm, Levy

# --- Brownian Motion ---
bm = Bm(start_position=0.0, diffusion_coefficient=1.0)
# Simulate trajectory
times, positions = bm.simulate(duration=10.0, time_step=0.01)
# Calculate First Passage Time (FPT) for domain (-1, 1)
fpt = bm.fpt(domain=(-1, 1))

# --- Fractional Brownian Motion ---
fbm = FBm(hurst_exponent=0.7)
# Calculate Time-Averaged Mean Squared Displacement (TAMSD)
tamsd = fbm.tamsd(duration=10.0, delta=1.0)

# --- Alpha-Stable Lévy Process ---
levy = Levy(alpha=1.5)
# Calculate Occupation Time in domain (-1, 1)
occ_time = levy.occupation_time(domain=(-1, 1), duration=10.0)

Features

Random Number Generation (diffusionx.random)

  • Gaussian: randn
  • Uniform: uniform
  • Exponential: randexp
  • Poisson: poisson
  • $\alpha$-Stable: stable_rand, skew_stable_rand
  • Bernoulli: bool_rand

Stochastic Processes (diffusionx.simulation)

Diffusions & Lévy Processes

  • Brownian Motion (Bm)
  • Geometric Brownian Motion (GeometricBm)
  • Fractional Brownian Motion (FBm)
  • Lévy Process (Levy, AsymmetricLevy)
  • Cauchy Process (Cauchy, AsymmetricCauchy)
  • Gamma Process (Gamma)
  • Ornstein-Uhlenbeck Process (OU)

Subordinators

  • Stable Subordinator (Subordinator)
  • Inverse Stable Subordinator (InvSubordinator)

Langevin Dynamics

  • Langevin Equation (Langevin)
  • Generalized Langevin Equation (GeneralizedLangevin)
  • Subordinated Langevin Equation (SubordinatedLangevin)

Brownian Functionals

  • Brownian Bridge (BrownianBridge)
  • Brownian Excursion (BrownianExcursion)
  • Brownian Meander (BrownianMeander)

Others

  • Continuous Time Random Walk (CTRW)
  • Poisson Process (Poisson)
  • Lévy Walk (LevyWalk)

Functionals

Support for calculating various functionals across most processes:

  • FPT: First Passage Time (and moments)
  • Occupation Time: Time spent in a domain (and moments)
  • MSD/TAMSD: Mean Squared Displacement metrics

Benchmark

Performance benchmark tests compare the Rust, C++, Julia, and Python implementations, which can be found here.

License

This project is dual-licensed under:

You can choose to use either license.

Contribution

Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

diffusionx-0.3.0.tar.gz (61.3 kB view details)

Uploaded Source

Built Distributions

If you're not sure about the file name format, learn more about wheel file names.

diffusionx-0.3.0-cp313-cp313t-win_amd64.whl (1.4 MB view details)

Uploaded CPython 3.13tWindows x86-64

diffusionx-0.3.0-cp313-cp313t-manylinux_2_28_x86_64.whl (1.6 MB view details)

Uploaded CPython 3.13tmanylinux: glibc 2.28+ x86-64

diffusionx-0.3.0-cp313-cp313t-manylinux_2_28_aarch64.whl (1.5 MB view details)

Uploaded CPython 3.13tmanylinux: glibc 2.28+ ARM64

diffusionx-0.3.0-cp313-cp313t-macosx_11_0_arm64.whl (1.3 MB view details)

Uploaded CPython 3.13tmacOS 11.0+ ARM64

diffusionx-0.3.0-cp313-cp313t-macosx_10_12_x86_64.whl (1.4 MB view details)

Uploaded CPython 3.13tmacOS 10.12+ x86-64

diffusionx-0.3.0-cp311-abi3-win_arm64.whl (1.2 MB view details)

Uploaded CPython 3.11+Windows ARM64

diffusionx-0.3.0-cp311-abi3-win_amd64.whl (1.4 MB view details)

Uploaded CPython 3.11+Windows x86-64

diffusionx-0.3.0-cp311-abi3-manylinux_2_28_x86_64.whl (1.6 MB view details)

Uploaded CPython 3.11+manylinux: glibc 2.28+ x86-64

diffusionx-0.3.0-cp311-abi3-manylinux_2_28_aarch64.whl (1.5 MB view details)

Uploaded CPython 3.11+manylinux: glibc 2.28+ ARM64

diffusionx-0.3.0-cp311-abi3-macosx_11_0_arm64.whl (1.3 MB view details)

Uploaded CPython 3.11+macOS 11.0+ ARM64

diffusionx-0.3.0-cp311-abi3-macosx_10_12_x86_64.whl (1.5 MB view details)

Uploaded CPython 3.11+macOS 10.12+ x86-64

File details

Details for the file diffusionx-0.3.0.tar.gz.

File metadata

  • Download URL: diffusionx-0.3.0.tar.gz
  • Upload date:
  • Size: 61.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for diffusionx-0.3.0.tar.gz
Algorithm Hash digest
SHA256 383ebc4aa4e8e5e17006f2f18c0b3cef0b88dc364dab5dc9f03a8be1d738d350
MD5 d07af6248af800bd113e90aa521a484e
BLAKE2b-256 9f9f0d08f8f84dd80363bc2383a5d6ae40a8800aed7ffbec073dbb09c52f8b97

See more details on using hashes here.

Provenance

The following attestation bundles were made for diffusionx-0.3.0.tar.gz:

Publisher: publish.yml on tangxiangong/py-diffusionx

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file diffusionx-0.3.0-cp313-cp313t-win_amd64.whl.

File metadata

  • Download URL: diffusionx-0.3.0-cp313-cp313t-win_amd64.whl
  • Upload date:
  • Size: 1.4 MB
  • Tags: CPython 3.13t, Windows x86-64
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for diffusionx-0.3.0-cp313-cp313t-win_amd64.whl
Algorithm Hash digest
SHA256 65e74a7381358aea0e7d8041a02123912257d8267f4c3365ed3295cb68292d25
MD5 c14564fd6735030fac5e8e4038ef0926
BLAKE2b-256 5525a43f873274b8b3e771c073cbe6604e7d6b5d1a3b39417246d6c1e58aea35

See more details on using hashes here.

Provenance

The following attestation bundles were made for diffusionx-0.3.0-cp313-cp313t-win_amd64.whl:

Publisher: publish.yml on tangxiangong/py-diffusionx

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file diffusionx-0.3.0-cp313-cp313t-manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for diffusionx-0.3.0-cp313-cp313t-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 57498a28e6a67754e44cf8f4a28ff91f818c462db0362c4fe98eedb94d98cebb
MD5 9412f43aafec57ac3b46a00fab4dfa81
BLAKE2b-256 021a7b4b09ba8066b3a8b00134c35e1d26fe4963ef4d03ac9f236bf4cf3c448c

See more details on using hashes here.

Provenance

The following attestation bundles were made for diffusionx-0.3.0-cp313-cp313t-manylinux_2_28_x86_64.whl:

Publisher: publish.yml on tangxiangong/py-diffusionx

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file diffusionx-0.3.0-cp313-cp313t-manylinux_2_28_aarch64.whl.

File metadata

File hashes

Hashes for diffusionx-0.3.0-cp313-cp313t-manylinux_2_28_aarch64.whl
Algorithm Hash digest
SHA256 f0adc0c0faeaa271da199bf40f2857b0ef46cb377722319f395054de30bcc46a
MD5 ae2c196d20e95e5672cd465ec301e2c0
BLAKE2b-256 f4d4ad646970b23dfe239536b5e225815e7144e93d1a77d9536da696db603f3f

See more details on using hashes here.

Provenance

The following attestation bundles were made for diffusionx-0.3.0-cp313-cp313t-manylinux_2_28_aarch64.whl:

Publisher: publish.yml on tangxiangong/py-diffusionx

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file diffusionx-0.3.0-cp313-cp313t-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for diffusionx-0.3.0-cp313-cp313t-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 7453b8a0c15edc8ee6a93d1dc6e2c8c291511327a4571b479a73c86d20b4c7e7
MD5 c781cc953f8c7ade65bf479d9ce67cd8
BLAKE2b-256 25c04be060792da8770c15ddd31f2794200b61c26d0dc1523db72b49a113c51b

See more details on using hashes here.

Provenance

The following attestation bundles were made for diffusionx-0.3.0-cp313-cp313t-macosx_11_0_arm64.whl:

Publisher: publish.yml on tangxiangong/py-diffusionx

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file diffusionx-0.3.0-cp313-cp313t-macosx_10_12_x86_64.whl.

File metadata

File hashes

Hashes for diffusionx-0.3.0-cp313-cp313t-macosx_10_12_x86_64.whl
Algorithm Hash digest
SHA256 82cd57865aaea72d2c283ccfa7e92cc6736bedafeb6360318295aae302973cdb
MD5 288d1d694a292729965c86505caf4227
BLAKE2b-256 dd5f47fe14e97601857d0b4d2e708f181e546652328d71ebcecf44606cefe02f

See more details on using hashes here.

Provenance

The following attestation bundles were made for diffusionx-0.3.0-cp313-cp313t-macosx_10_12_x86_64.whl:

Publisher: publish.yml on tangxiangong/py-diffusionx

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file diffusionx-0.3.0-cp311-abi3-win_arm64.whl.

File metadata

  • Download URL: diffusionx-0.3.0-cp311-abi3-win_arm64.whl
  • Upload date:
  • Size: 1.2 MB
  • Tags: CPython 3.11+, Windows ARM64
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for diffusionx-0.3.0-cp311-abi3-win_arm64.whl
Algorithm Hash digest
SHA256 304c4c88b6f0529ffeb500709359f59c3d424a06d7fda6d6cdb82114d1a747cd
MD5 aec65d8fc959c7e776445cf9f02f7106
BLAKE2b-256 f49930df1976eab66850de3d74a841f5731e2affccd1f4f255cd3206bcf28acb

See more details on using hashes here.

Provenance

The following attestation bundles were made for diffusionx-0.3.0-cp311-abi3-win_arm64.whl:

Publisher: publish.yml on tangxiangong/py-diffusionx

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file diffusionx-0.3.0-cp311-abi3-win_amd64.whl.

File metadata

  • Download URL: diffusionx-0.3.0-cp311-abi3-win_amd64.whl
  • Upload date:
  • Size: 1.4 MB
  • Tags: CPython 3.11+, Windows x86-64
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for diffusionx-0.3.0-cp311-abi3-win_amd64.whl
Algorithm Hash digest
SHA256 1a55908b6dc74ad5687330f1f4b04d7ecc203a0b00e5c201817172255740b19a
MD5 6f46b85fe25e0c8b34fa2e13895d79fb
BLAKE2b-256 c0ba64d187d66e0e1e02f52fb95e689a873e03a42345b577a78c3e6708b55cbb

See more details on using hashes here.

Provenance

The following attestation bundles were made for diffusionx-0.3.0-cp311-abi3-win_amd64.whl:

Publisher: publish.yml on tangxiangong/py-diffusionx

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file diffusionx-0.3.0-cp311-abi3-manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for diffusionx-0.3.0-cp311-abi3-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 dd235752c42b81be664862abb0cc1fa205cf22345602d5c963d3bb321a9f126b
MD5 c380ea5bb08a0d6abd992e2d17abf7fa
BLAKE2b-256 9267badd4d2ad4eb10ed01fa471d9cfa1be685efd11d78c08f7e9f34c5baeb7d

See more details on using hashes here.

Provenance

The following attestation bundles were made for diffusionx-0.3.0-cp311-abi3-manylinux_2_28_x86_64.whl:

Publisher: publish.yml on tangxiangong/py-diffusionx

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file diffusionx-0.3.0-cp311-abi3-manylinux_2_28_aarch64.whl.

File metadata

File hashes

Hashes for diffusionx-0.3.0-cp311-abi3-manylinux_2_28_aarch64.whl
Algorithm Hash digest
SHA256 8d27cbf452166dd394818cd00126113370c1e1bbca641764e8a5a700849ea2ec
MD5 92b54b32fa9e146719c8e0cd5ae30d39
BLAKE2b-256 ff72abfe7874b313cea6bbc5bb1bb7bfced3f7fd4d633457e07802560139514f

See more details on using hashes here.

Provenance

The following attestation bundles were made for diffusionx-0.3.0-cp311-abi3-manylinux_2_28_aarch64.whl:

Publisher: publish.yml on tangxiangong/py-diffusionx

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file diffusionx-0.3.0-cp311-abi3-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for diffusionx-0.3.0-cp311-abi3-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 af1d815345ba23e6c0ee3d0cb9f33a3c0ec8aeef10d08b1cf38f432a15740a35
MD5 d6543285cca1a3ecb877415d4456f4ef
BLAKE2b-256 f4a69d4f2c561aa01fdae496fbec7e3f8fe99c3bbae7bc1c71bc959467b09ca3

See more details on using hashes here.

Provenance

The following attestation bundles were made for diffusionx-0.3.0-cp311-abi3-macosx_11_0_arm64.whl:

Publisher: publish.yml on tangxiangong/py-diffusionx

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file diffusionx-0.3.0-cp311-abi3-macosx_10_12_x86_64.whl.

File metadata

File hashes

Hashes for diffusionx-0.3.0-cp311-abi3-macosx_10_12_x86_64.whl
Algorithm Hash digest
SHA256 178cc36354e55cc7d764b1609d95b5b0c7e86817a2a26d63e7c39e8ee398ceb9
MD5 6671299dc20203faf2caaf7174e1a546
BLAKE2b-256 47b9058ee493e849aa247232554a27dd27a0ac652b243a08f2b9a0127e5e05ce

See more details on using hashes here.

Provenance

The following attestation bundles were made for diffusionx-0.3.0-cp311-abi3-macosx_10_12_x86_64.whl:

Publisher: publish.yml on tangxiangong/py-diffusionx

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page