SSMS is a package collecting simulators and training data generators for cognitive science, neuroscience, and approximate bayesian computation
Project description
SSMS (Sequential Sampling Model Simulators)
Python Package to collect simulators for Sequential Sampling Models.
Find the package documentation here.
Quick Start
The ssms package serves two purposes.
- Easy access to fast simulators of sequential sampling models
- Support infrastructure to construct training data for various approaches to likelihood / posterior amortization
A number of tutorial notebooks are available under the /notebooks directory.
Installation
pip install ssm-simulators
Recommended: Install via conda-forge for full parallel support:
conda install -c conda-forge ssm-simulators
[!NOTE] Parallel Execution Requirements:
For multi-threaded simulation (
n_threads > 1), the package requires:
- OpenMP: For parallel loop execution
- GSL (GNU Scientific Library): For validated random number generation
conda-forge users: Both dependencies are automatically included.
pip users: Install system dependencies first:
# macOS brew install libomp gsl # Ubuntu/Debian sudo apt-get install libgomp-dev libgsl-devThen reinstall:
pip install --force-reinstall ssm-simulatorsWithout these dependencies, the package works in single-threaded mode using NumPy.
[!NOTE] Building from source or developing this package requires a C compiler (such as GCC). On Linux, you can install GCC with:
sudo apt-get install build-essentialMost users installing from PyPI wheels do not need to install GCC.
Parallel Execution Details
When using n_threads > 1, the package uses GSL's validated Ziggurat algorithm for
Gaussian random number generation, ensuring statistically correct simulations.
Thread Limit: The maximum supported number of threads is 256 (compile-time limit).
Requesting more threads will raise a ValueError. This limit exists because per-thread
random number generator states are allocated as static arrays for performance.
from ssms.basic_simulators import simulator
# Single-threaded (uses NumPy RNG)
result = simulator.simulator(model='ddm', theta=theta, n_samples=10000, n_threads=1)
# Multi-threaded (uses GSL Ziggurat RNG, requires OpenMP + GSL)
result = simulator.simulator(model='ddm', theta=theta, n_samples=10000, n_threads=8)
Check your installation's parallel capabilities:
from cssm._openmp_status import print_status
print_status()
Command Line Interface
The package exposes a command-line tool, generate, for creating training data from a YAML configuration file.
generate --config-path <path/to/config.yaml> --output <output/directory> [--log-level INFO]
--config-path: Path to your YAML configuration file (optional, uses default if not provided).--output: Directory where generated data will be saved (required).--n-files: (Optional) Number of data files to generate. Default is1file.--estimator-type: (Optional) Likelihood estimator type (kdeorpyddm). Overrides YAML config if specified.--log-level: (Optional) Set the logging level (DEBUG,INFO,WARNING,ERROR,CRITICAL). Default isWARNING.
Below is a sample YAML configuration you can use with the generate command:
MODEL: 'ddm'
GENERATOR_APPROACH: 'lan'
PIPELINE:
N_PARAMETER_SETS: 100
N_SUBRUNS: 20
SIMULATOR:
N_SAMPLES: 2000
DELTA_T: 0.001
TRAINING:
N_SAMPLES_PER_PARAM: 200
ESTIMATOR:
TYPE: 'kde' # Options: 'kde' (default) or 'pyddm'
Configuration file parameter details follow.
Top-Level Parameters:
| Option | Definition |
|---|---|
MODEL |
The type of model you want to simulate (e.g., ddm, angle, levy) |
GENERATOR_APPROACH |
Type of generator used to generate data (lan or cpn) |
PIPELINE Section:
| Option | Definition |
|---|---|
N_PARAMETER_SETS |
Number of parameter vectors that are used for training |
N_SUBRUNS |
Number of repetitions of each call to generate data |
SIMULATOR Section:
| Option | Definition |
|---|---|
N_SAMPLES |
Number of samples a simulation run should entail for a given parameter set |
DELTA_T |
Time discretization step used in numerical simulation of the model. Interval between updates of evidence-accumulation. |
TRAINING Section:
| Option | Definition |
|---|---|
N_SAMPLES_PER_PARAM |
Number of times the kernel density estimate (KDE) is evaluated after creating the KDE from simulations of each set of model parameters |
ESTIMATOR Section:
| Option | Definition |
|---|---|
TYPE |
Likelihood estimator type: kde (default) or pyddm |
To make your own configuration file, you can copy the example above into a new .yaml file and modify it with your preferences.
If you are using uv (see below), you can use the uv run command to run generate from the command line
This will generate training data according to your configuration and save it in the specified output directory.
Key Features
Custom Parameter Transforms
Register custom transformations to apply model-specific modifications to sampled parameters:
from ssms import register_transform_function
import numpy as np
# Register a custom transform
def exponential_drift(theta: dict) -> dict:
if 'v' in theta:
theta['v'] = np.exp(theta['v'])
return theta
register_transform_function("exp_v", exponential_drift)
# Use in model configuration
model_config = {
"name": "my_model",
"params": ["v", "a", "z", "t"],
"param_bounds": [...],
"parameter_transforms": [
{"type": "exp_v"} # Your custom transform
]
}
Tutorial
Check the basic tutorial in our documentation.
Advanced: Dependency Management with uv
We use uv for fast and efficient dependency management. To get started:
- Install
uv:
curl -LsSf https://astral.sh/uv/install.sh | sh
- Install dependencies (including development):
uv sync --all-groups # Installs all dependency groups
Building Cython Extensions from Source
For development or to rebuild with different settings:
# Clean environment and sync
rm -rf .venv && uv sync
# Rebuild Cython extensions (editable install)
uv pip install --python .venv/bin/python -e . --reinstall
Important: Always use uv pip install --python .venv/bin/python to ensure extensions
are built for the correct Python version in your virtual environment.
Contributing
We welcome contributions from the community! Whether you want to add a new model, improve documentation, or fix bugs, your help is appreciated.
Contributing New Models
Want to add your own sequential sampling model to the package? Check out our comprehensive guide:
📖 Contributing New Models Tutorial
This guide walks you through three levels of contribution:
- Level 1: Add boundary/drift variants (~15 min)
- Level 2: Implement Python simulators (~20 min)
- Level 3: Create high-performance Cython implementations (~30 min)
Other Contributions
For bug reports, feature requests, or general questions:
- Open an issue on GitHub Issues
- Check existing issues to avoid duplicates
- Provide clear descriptions and reproducible examples
Cite ssm-simulators
Please use the this DOI to cite ssm-simulators: https://doi.org/10.5281/zenodo.17156205
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distributions
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file ssm_simulators-0.12.3.tar.gz.
File metadata
- Download URL: ssm_simulators-0.12.3.tar.gz
- Upload date:
- Size: 2.4 MB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
a54bcc0834a46a3e818249eede89cacb9d0e84ad80ff8138023fa56b32e27973
|
|
| MD5 |
dadb8873d3457bb6d578ec699ddeeb69
|
|
| BLAKE2b-256 |
6b39df631b2b3ad6e4e3bbdf2ef560f016629ec4f1f6f7965898920f9a998e73
|
File details
Details for the file ssm_simulators-0.12.3-cp312-cp312-win_amd64.whl.
File metadata
- Download URL: ssm_simulators-0.12.3-cp312-cp312-win_amd64.whl
- Upload date:
- Size: 3.6 MB
- Tags: CPython 3.12, Windows x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
8b0f49aa0d541c4f34c16c7a09f842619ecf521b8257c224726bb1d3e1c6de1f
|
|
| MD5 |
9501888bc4465f13128e8df057b0aebe
|
|
| BLAKE2b-256 |
abccfdda6d33c5f3dab10c918419f3a321a3009ce1227d4f55770d4bc79bb3d4
|
File details
Details for the file ssm_simulators-0.12.3-cp312-cp312-musllinux_1_2_x86_64.whl.
File metadata
- Download URL: ssm_simulators-0.12.3-cp312-cp312-musllinux_1_2_x86_64.whl
- Upload date:
- Size: 11.7 MB
- Tags: CPython 3.12, musllinux: musl 1.2+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
1816a96e868830edc6be057f0b44f6a2eb2df8569d5828f20fe7b33c65f99584
|
|
| MD5 |
db57c912ea93894fc921b46287194885
|
|
| BLAKE2b-256 |
a032c23abf14f7773382c62fa77a6d784ec884afb79a6a61ca8cbc8f50eacb7d
|
File details
Details for the file ssm_simulators-0.12.3-cp312-cp312-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl.
File metadata
- Download URL: ssm_simulators-0.12.3-cp312-cp312-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl
- Upload date:
- Size: 11.7 MB
- Tags: CPython 3.12, manylinux: glibc 2.17+ x86-64, manylinux: glibc 2.28+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
5c5bb8efccd1866a24511ae9f5c43efa8b508e37b36aa885a268f9bfc688c7ef
|
|
| MD5 |
0fe08e36d725662810ae6dad6df1717b
|
|
| BLAKE2b-256 |
016404ba93867f52e644c83c7ba5dfdde529d1943ec2e9ca590d04ac232e1ace
|
File details
Details for the file ssm_simulators-0.12.3-cp312-cp312-macosx_11_0_arm64.whl.
File metadata
- Download URL: ssm_simulators-0.12.3-cp312-cp312-macosx_11_0_arm64.whl
- Upload date:
- Size: 3.7 MB
- Tags: CPython 3.12, macOS 11.0+ ARM64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
4d2263bbd85d9ef0cc32ebae53c5d4fd0a8d5b22a22a3470a2e4fa7b2daf2e17
|
|
| MD5 |
9176e68e88de98d10d6c44fb282736fd
|
|
| BLAKE2b-256 |
219792992f3656472dc4baf64af53a570da520c2ebd801212428d332fb3a48b8
|
File details
Details for the file ssm_simulators-0.12.3-cp312-cp312-macosx_10_13_x86_64.whl.
File metadata
- Download URL: ssm_simulators-0.12.3-cp312-cp312-macosx_10_13_x86_64.whl
- Upload date:
- Size: 3.8 MB
- Tags: CPython 3.12, macOS 10.13+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
f8126fb48a9e7439e2cdeca1806f137fe8c40d5d01ddcbf102e86102435c1f7a
|
|
| MD5 |
997063ca2117bf4cb7c4a00b67fe32ed
|
|
| BLAKE2b-256 |
b6b82d560f5fd83da6a3c93b0db672fe52bcc3daae2122a9850c38af6cd3a1c4
|
File details
Details for the file ssm_simulators-0.12.3-cp311-cp311-win_amd64.whl.
File metadata
- Download URL: ssm_simulators-0.12.3-cp311-cp311-win_amd64.whl
- Upload date:
- Size: 3.6 MB
- Tags: CPython 3.11, Windows x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
954e746dccd5e77c3c58c7dde9300327ff654d9950226e2f18a0607f59657c03
|
|
| MD5 |
133e8dda8e0c1afe2510bba6ddbfc6b4
|
|
| BLAKE2b-256 |
4c40a80b44d8f52fd2ad2fe4c37b18b9f1ac76c8ffb584fc1c32b0861a26b9d6
|
File details
Details for the file ssm_simulators-0.12.3-cp311-cp311-musllinux_1_2_x86_64.whl.
File metadata
- Download URL: ssm_simulators-0.12.3-cp311-cp311-musllinux_1_2_x86_64.whl
- Upload date:
- Size: 12.0 MB
- Tags: CPython 3.11, musllinux: musl 1.2+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
adfa05101f6d5b717448582ba91e804ae89cfe2d900db164bfc806bb52ddac27
|
|
| MD5 |
c08c268ece229d1d9ac05dfdb8918ebb
|
|
| BLAKE2b-256 |
ab059df6b2365e5ae2816326b45cd81d932ee8b18d49d558240e0b48b71a7e15
|
File details
Details for the file ssm_simulators-0.12.3-cp311-cp311-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl.
File metadata
- Download URL: ssm_simulators-0.12.3-cp311-cp311-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl
- Upload date:
- Size: 11.9 MB
- Tags: CPython 3.11, manylinux: glibc 2.17+ x86-64, manylinux: glibc 2.28+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
8218b19b2ef7e346adb28ae861156815549357cf9b839c9df8ee6921d34c2ee3
|
|
| MD5 |
38ccbbb4aa9a12d5f65690ccdb94b4a6
|
|
| BLAKE2b-256 |
356efd23cf4f9ad706b0b0e6810f943223aa9f580bdc47bfacb0ada012264c52
|
File details
Details for the file ssm_simulators-0.12.3-cp311-cp311-macosx_11_0_arm64.whl.
File metadata
- Download URL: ssm_simulators-0.12.3-cp311-cp311-macosx_11_0_arm64.whl
- Upload date:
- Size: 3.7 MB
- Tags: CPython 3.11, macOS 11.0+ ARM64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
419090d7f0a7fb636c22b274f54a3cbcfa226c7ae061ba3474105543e6893154
|
|
| MD5 |
2b3800a21a5c6a3784c9288e4313104d
|
|
| BLAKE2b-256 |
cf554df20088cdd0d50903576464e888c5e7698416ad9fc859d63cc539501f12
|
File details
Details for the file ssm_simulators-0.12.3-cp311-cp311-macosx_10_9_x86_64.whl.
File metadata
- Download URL: ssm_simulators-0.12.3-cp311-cp311-macosx_10_9_x86_64.whl
- Upload date:
- Size: 3.8 MB
- Tags: CPython 3.11, macOS 10.9+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
7be8c6c1d226ef82222d0dd5658e74f0fcc2b2ee58f77a2dde59e6501f81229a
|
|
| MD5 |
fd3143e5d7abd4d36b3ba2006b44b27b
|
|
| BLAKE2b-256 |
c7f86cc549cfe407eb63428dc68290e4b23a82e24b4827970dbd626a1b1d2bf0
|