Skip to main content

stochastix

Differentiable, hardware accelerated stochastic kinetic models in JAX.

Installation • Quick Example • Documentation • Citation

The main purpose of this library is to provide a high-level, fairly flexible implementation of stochastic simulations of kinetic models (also commonly referred to as Gillespie simulations from the author of the most used solvers).

The design is heavily inspired by the Diffrax library for solution of differential equations and heavily relies on the infrastructure provided by Equinox. All of this is built on top of JAX, if you are new to this world you might want to take a quick look at some basic JAX Tutorials.

Basic usage of the main stochastix API for running forward simulations should require only a minimal knowledge of JAX.

Main features:

  • Automatic GPU/TPU acceleration, JIT compilation, and vectorization via JAX
  • Exact, approximate, and pathwise differentiable stochastic solvers (DirectMethod, TauLeaping, DifferentiableDirect, DGA, etc.)
  • Seamless integration with the JAX ecosystem (Equinox, Diffrax, Optax, etc.)
  • Automatic conversion between CME (jump process), CLE (stochastic differential equation), and ODE (deterministic differential equation) models for Diffrax integration
  • Built-in kinetics (MassAction, Hill, Michaelis–Menten) and support for learnable neural network propensities
  • Controllers for time-based interventions during simulations
  • Likelihood computation via log_prob for exact trajectories and helpers for REINFORCE-style training
  • Analysis utilities: differentiable autocorrelation, cross-correlation, histograms, and mutual information

Installation

GPU support

stochastix (as all other JAX-based libraries) relies on JAX for hardware acceleration support. To run on GPU or other accelerators, you need to install the appropriate JAX version. If JAX is not already present, the standard stochastix installation will automatically install the CPU version.

Please refer to the JAX installation guide for the latest guidelines.

pip

To install the package and core dependencies:

pip install stochastix

or directly from the repository:

pip install git+https://github.com/fmottes/stochastix.git

Note: in order to run the Jupyter notebooks, you need to install the optional dependencies:

pip install stochastix[notebooks]

uv

You can add the package to your project dependencies with:

uv add stochastix

For all other uv installation options, see the uv docs.

Quick Example

A basic simulation of a chain reaction with Gillespie's direct method:

import jax
import jax.numpy as jnp

import stochastix as stx
from stochastix.kinetics import MassAction

# simple reaction chain with mass action rates
network = stx.ReactionNetwork(
    [
        stx.Reaction('0 -> X', MassAction(k=0.01)),
        stx.Reaction('X -> Y', MassAction(k=0.002)),
    ]
)


x0 = jnp.array([0, 0])  # initial conditions [X, Y]
sim_key = jax.random.PRNGKey(0)  # key for jax random number generator

# solve with direct method from t0=0 to t1=100
sim_results = stx.stochsimsolve(sim_key, network, x0, T=100.0)

Diving deeper

Citation

If you use this software, please cite the paper:

Gradient-based optimization of exact stochastic kinetic models Francesco Mottes, Qian-Ze Zhu, Michael P. Brenner arXiv:2601.14183 (2026)

You can use the "Cite this repository" button in the top right corner of the repository page to get the citation in various formats.

Metadata

Release files for stochastix 0.2.1

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

Source distribution (sdist)

Source distribution for stochastix 0.2.1
File Size Uploaded Provenance Actions
stochastix-0.2.1.tar.gz 255.2 kB With provenance Details for stochastix-0.2.1.tar.gz

Built distribution (wheel)

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

Total release size: 352.5 kB

Release files / stochastix-0.2.1.tar.gz

Download URL stochastix-0.2.1.tar.gz
Size 255.2 kB
Tags Source
SHA-256 checksum
How to use checksums
42651a7981749bfe9b9ca7b243fbf555553e882b05f0628d1d79a39662bcdb79
BLAKE2b-256 checksum
How to use checksums
3935310ca520868d6267159792b0c40e6e02af6130bf30845d2dd93549b79ac8
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

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.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 30, 2026.

Transparency log

Release files / stochastix-0.2.1-py3-none-any.whl

Download URL stochastix-0.2.1-py3-none-any.whl
Size 97.3 kB
Tags Python 3
SHA-256 checksum
How to use checksums
e4c3a968944aa248b908086ebcfc02d8958cbcdd35e7566d209189b936323ffc
BLAKE2b-256 checksum
How to use checksums
59c53e4c79ad2a69792fb41cff9b57c676c172614b542170b04ff4d20eb6a4fd
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

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.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 30, 2026.

Transparency log

Security for stochastix 0.2.1

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.

Full provenance

Both files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for stochastix-0.2.1.tar.gz

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 30, 2026.

Transparency log

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