Skip to main content

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)

DOI PyPI PyPI_dl GitHub pull requests Python Version Run tests Ruff License: MIT codecov

Python Package to collect simulators for Sequential Sampling Models.

Find the package documentation here.

Quick Start

The ssms package serves two purposes.

  1. Easy access to fast simulators of sequential sampling models
  2. 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

Install the optional JAX backend for differentiable RLSSM learning processes:

pip install "ssm-simulators[jax]"

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-dev

Then reinstall: pip install --force-reinstall ssm-simulators

Without 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-essential

Most 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 is 1 file.
  • --estimator-type: (Optional) Likelihood estimator type (kde or pyddm). Overrides YAML config if specified.
  • --log-level: (Optional) Set the logging level (DEBUG, INFO, WARNING, ERROR, CRITICAL). Default is WARNING.

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:

  1. Install uv:
curl -LsSf https://astral.sh/uv/install.sh | sh
  1. 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


Download files

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

Source Distribution

ssm_simulators-0.12.4.tar.gz (2.4 MB view details)

Uploaded Source

Built Distributions

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

ssm_simulators-0.12.4-cp314-cp314-win_amd64.whl (3.7 MB view details)

Uploaded CPython 3.14Windows x86-64

ssm_simulators-0.12.4-cp314-cp314-musllinux_1_2_x86_64.whl (11.7 MB view details)

Uploaded CPython 3.14musllinux: musl 1.2+ x86-64

ssm_simulators-0.12.4-cp314-cp314-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl (11.7 MB view details)

Uploaded CPython 3.14manylinux: glibc 2.17+ x86-64manylinux: glibc 2.28+ x86-64

ssm_simulators-0.12.4-cp314-cp314-macosx_11_0_arm64.whl (3.8 MB view details)

Uploaded CPython 3.14macOS 11.0+ ARM64

ssm_simulators-0.12.4-cp314-cp314-macosx_10_15_x86_64.whl (3.9 MB view details)

Uploaded CPython 3.14macOS 10.15+ x86-64

ssm_simulators-0.12.4-cp313-cp313-win_amd64.whl (3.7 MB view details)

Uploaded CPython 3.13Windows x86-64

ssm_simulators-0.12.4-cp313-cp313-musllinux_1_2_x86_64.whl (11.8 MB view details)

Uploaded CPython 3.13musllinux: musl 1.2+ x86-64

ssm_simulators-0.12.4-cp313-cp313-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl (11.7 MB view details)

Uploaded CPython 3.13manylinux: glibc 2.17+ x86-64manylinux: glibc 2.28+ x86-64

ssm_simulators-0.12.4-cp313-cp313-macosx_11_0_arm64.whl (3.7 MB view details)

Uploaded CPython 3.13macOS 11.0+ ARM64

ssm_simulators-0.12.4-cp313-cp313-macosx_10_13_x86_64.whl (3.8 MB view details)

Uploaded CPython 3.13macOS 10.13+ x86-64

ssm_simulators-0.12.4-cp312-cp312-win_amd64.whl (3.7 MB view details)

Uploaded CPython 3.12Windows x86-64

ssm_simulators-0.12.4-cp312-cp312-musllinux_1_2_x86_64.whl (11.8 MB view details)

Uploaded CPython 3.12musllinux: musl 1.2+ x86-64

ssm_simulators-0.12.4-cp312-cp312-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl (11.8 MB view details)

Uploaded CPython 3.12manylinux: glibc 2.17+ x86-64manylinux: glibc 2.28+ x86-64

ssm_simulators-0.12.4-cp312-cp312-macosx_11_0_arm64.whl (3.8 MB view details)

Uploaded CPython 3.12macOS 11.0+ ARM64

ssm_simulators-0.12.4-cp312-cp312-macosx_10_13_x86_64.whl (3.8 MB view details)

Uploaded CPython 3.12macOS 10.13+ x86-64

ssm_simulators-0.12.4-cp311-cp311-win_amd64.whl (3.7 MB view details)

Uploaded CPython 3.11Windows x86-64

ssm_simulators-0.12.4-cp311-cp311-musllinux_1_2_x86_64.whl (12.1 MB view details)

Uploaded CPython 3.11musllinux: musl 1.2+ x86-64

ssm_simulators-0.12.4-cp311-cp311-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl (12.0 MB view details)

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

ssm_simulators-0.12.4-cp311-cp311-macosx_11_0_arm64.whl (3.8 MB view details)

Uploaded CPython 3.11macOS 11.0+ ARM64

ssm_simulators-0.12.4-cp311-cp311-macosx_10_9_x86_64.whl (3.9 MB view details)

Uploaded CPython 3.11macOS 10.9+ x86-64

File details

Details for the file ssm_simulators-0.12.4.tar.gz.

File metadata

  • Download URL: ssm_simulators-0.12.4.tar.gz
  • Upload date:
  • Size: 2.4 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for ssm_simulators-0.12.4.tar.gz
Algorithm Hash digest
SHA256 56cd288aff4c0fe1d3a07395900f66ab372c7d37e622ab648de2957d9c4599e8
MD5 736d74b9b491d1da3922e0d15776c49c
BLAKE2b-256 e7beee8ed1eb9277ddb7d145cb0f7352b970f79aa1ad7a95a0c91deb1f5a506d

See more details on using hashes here.

File details

Details for the file ssm_simulators-0.12.4-cp314-cp314-win_amd64.whl.

File metadata

File hashes

Hashes for ssm_simulators-0.12.4-cp314-cp314-win_amd64.whl
Algorithm Hash digest
SHA256 433fb6be3a50cfcd33526947896d3722aab852c5aabb4c660ea7432128ead1bc
MD5 548dc12cd99eaeddf9e4488aa2abccda
BLAKE2b-256 5fefb6d5ac63cd5d79bc20ce0a635bea5c7dfea963590cc8357735e0bcd0288d

See more details on using hashes here.

File details

Details for the file ssm_simulators-0.12.4-cp314-cp314-musllinux_1_2_x86_64.whl.

File metadata

File hashes

Hashes for ssm_simulators-0.12.4-cp314-cp314-musllinux_1_2_x86_64.whl
Algorithm Hash digest
SHA256 acadf589378e912bce2408dfa312de2fc7fba2af559daa35e28a0668d366fe55
MD5 e16c77b47f8960c97a21b13a128cbcb2
BLAKE2b-256 1de53606da836cbf33d867e60fd791b0624f8d35fa4bd510d296bcdb8a210a6b

See more details on using hashes here.

File details

Details for the file ssm_simulators-0.12.4-cp314-cp314-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for ssm_simulators-0.12.4-cp314-cp314-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 3990b02f4e43ab98218ea7aae8196a3c7e27acb67f894188c88a9bd7affe91fb
MD5 dae554aadb90f070ed2ff13be0d78abf
BLAKE2b-256 7e46a5f000acd25a4aa25ecaea32dcd32a6ed2f9df50dfc766e846dd6b646255

See more details on using hashes here.

File details

Details for the file ssm_simulators-0.12.4-cp314-cp314-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for ssm_simulators-0.12.4-cp314-cp314-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 a8a41aa1b21977c51037cffc27e3309b4c12e22df187d00842a0a599f22d27b6
MD5 befe95b8c9f6db8f44e90623065f9b36
BLAKE2b-256 23ccddd761c687c1682c19ed9b04d9cd902b4d38758bf1e7870607fedad768b5

See more details on using hashes here.

File details

Details for the file ssm_simulators-0.12.4-cp314-cp314-macosx_10_15_x86_64.whl.

File metadata

File hashes

Hashes for ssm_simulators-0.12.4-cp314-cp314-macosx_10_15_x86_64.whl
Algorithm Hash digest
SHA256 4f493c1f46e436dda9ee269f86ea605d9ed7bdd6f32e906de00a8b8577a9f518
MD5 d752eb86a94fc5ac1bccfda276b084ae
BLAKE2b-256 23337e9753ac3f2b59915bc770225f51538478e1d4be20585343313a4c81e7f1

See more details on using hashes here.

File details

Details for the file ssm_simulators-0.12.4-cp313-cp313-win_amd64.whl.

File metadata

File hashes

Hashes for ssm_simulators-0.12.4-cp313-cp313-win_amd64.whl
Algorithm Hash digest
SHA256 902104becc9fbd7809bbb7bf019c13eb54e55d70d9bb04910b29cb3be00890d5
MD5 5ccaa180ec8375f82a6d12f8d28d5e83
BLAKE2b-256 1dae66004195bfe4357f1b0f46b4c5e06d947617aa628859fb61e8171eef4daf

See more details on using hashes here.

File details

Details for the file ssm_simulators-0.12.4-cp313-cp313-musllinux_1_2_x86_64.whl.

File metadata

File hashes

Hashes for ssm_simulators-0.12.4-cp313-cp313-musllinux_1_2_x86_64.whl
Algorithm Hash digest
SHA256 cfa3f720bdfac1efb958d7ef3ef86b56a9dd563fcc6a43b44434d61f52f1eb95
MD5 3936be95cdad68c621dc71363dae01a4
BLAKE2b-256 1908d5c9624d57dde77de92187baf39a2dded1e301946d667ec3a579c27b8d48

See more details on using hashes here.

File details

Details for the file ssm_simulators-0.12.4-cp313-cp313-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for ssm_simulators-0.12.4-cp313-cp313-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 ab7c2907421f6cb3adcc1b479947addd58f9567d03ca1b8ff7ff6ef2a52ba1e6
MD5 3b10e74a294013b0452a9c1f5a7fe3aa
BLAKE2b-256 3e2b7c4a6152d02cc7df76c064340d2cf189c92117bbdb8f9e1c1d45e8ce57ae

See more details on using hashes here.

File details

Details for the file ssm_simulators-0.12.4-cp313-cp313-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for ssm_simulators-0.12.4-cp313-cp313-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 081023440dce1d17c1797df9ecb722409f6095d17d7556edb840b83941bc2938
MD5 941c62b6a68f2d5ba633fb858625725c
BLAKE2b-256 3617ca0b787fe6ec70a4cf81e7ebdc06c28feb33331fab3784f312d9b5d9fed0

See more details on using hashes here.

File details

Details for the file ssm_simulators-0.12.4-cp313-cp313-macosx_10_13_x86_64.whl.

File metadata

File hashes

Hashes for ssm_simulators-0.12.4-cp313-cp313-macosx_10_13_x86_64.whl
Algorithm Hash digest
SHA256 5013f22a7e6d691a22f7a648c5dc5baf2c7990cd72f53ef6496acd22d20b8fda
MD5 684274133416e5b64c93f84c51da333f
BLAKE2b-256 05d389228c4e7ec32357478041cc1c4f7d626217d3b965cad27eb3d48cc7be3f

See more details on using hashes here.

File details

Details for the file ssm_simulators-0.12.4-cp312-cp312-win_amd64.whl.

File metadata

File hashes

Hashes for ssm_simulators-0.12.4-cp312-cp312-win_amd64.whl
Algorithm Hash digest
SHA256 73c973e5ec31e73a2fd2452673296dfa94d9fa6582c589eb825a53c953dc852c
MD5 5c98309d83fe07fdedd9f939090942f5
BLAKE2b-256 aa2250d0790193bb180e150c80d606d10683964c413baeebcd799df28e2a2afa

See more details on using hashes here.

File details

Details for the file ssm_simulators-0.12.4-cp312-cp312-musllinux_1_2_x86_64.whl.

File metadata

File hashes

Hashes for ssm_simulators-0.12.4-cp312-cp312-musllinux_1_2_x86_64.whl
Algorithm Hash digest
SHA256 176503d590931bb46ecb3773a7cdb362677526be55cb67d4f6c629a6c7b6672a
MD5 773a8a815e3d03ef580b436d8dd42fe1
BLAKE2b-256 40086b331652ff13a9dd886187c8e3e3836b8bb9408f4db3007c7aecf4a07179

See more details on using hashes here.

File details

Details for the file ssm_simulators-0.12.4-cp312-cp312-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for ssm_simulators-0.12.4-cp312-cp312-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 e8724f1e7d59abd49da8a60ce8cdeb64640a8335b7021d63ba02219ec1e4a6ba
MD5 2cd83e2120643502365deb0b9edf2cb6
BLAKE2b-256 3bc5f24169d77249d4a1f0949b3eb896ab37d0f57f3615348cdbce3bfdf7c186

See more details on using hashes here.

File details

Details for the file ssm_simulators-0.12.4-cp312-cp312-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for ssm_simulators-0.12.4-cp312-cp312-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 1ec2ca77bd5e94513e12e17cca97baeed213bc84f5a57d7fdab8e8ca70d37373
MD5 8e3426957be4980f5fe9d7a186f4ec45
BLAKE2b-256 9b6b8d5e2071353631442c80069742b1c584ebcf1db223370c5218f3c2d92381

See more details on using hashes here.

File details

Details for the file ssm_simulators-0.12.4-cp312-cp312-macosx_10_13_x86_64.whl.

File metadata

File hashes

Hashes for ssm_simulators-0.12.4-cp312-cp312-macosx_10_13_x86_64.whl
Algorithm Hash digest
SHA256 1dedaf951ee88342e39e6c01314f7993fe6f8b4f73b704e2880c653885386fbc
MD5 90297ce000d28dc2dd89a05bbf82ea31
BLAKE2b-256 38aef9694dcbd275eb226ea465ed49b9d9ef83070d2a0f821143e0a3ea82160c

See more details on using hashes here.

File details

Details for the file ssm_simulators-0.12.4-cp311-cp311-win_amd64.whl.

File metadata

File hashes

Hashes for ssm_simulators-0.12.4-cp311-cp311-win_amd64.whl
Algorithm Hash digest
SHA256 d856102504bc99154b3ec90b3fff2437599a594c8fec5672a0a9ca2a937953d6
MD5 60b0899dd93c2d2a422779d3a854e693
BLAKE2b-256 c62fe534cc2654920000c5d852615b89d4e19a34d16228720919725f100253fc

See more details on using hashes here.

File details

Details for the file ssm_simulators-0.12.4-cp311-cp311-musllinux_1_2_x86_64.whl.

File metadata

File hashes

Hashes for ssm_simulators-0.12.4-cp311-cp311-musllinux_1_2_x86_64.whl
Algorithm Hash digest
SHA256 95514717de2073b0e3abceaa68ecbc6a3ad8f94d6a326a9d796acbdcf9b75c8f
MD5 a17b1a45e1261b41946655e7a666a75a
BLAKE2b-256 da6c5873dd57e3ceae91167b4c3ef09c248ae0896864bb0e7516d5657e77ccb5

See more details on using hashes here.

File details

Details for the file ssm_simulators-0.12.4-cp311-cp311-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for ssm_simulators-0.12.4-cp311-cp311-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 b3eac3c1a7e1687d5be9127ee964154aff2fae1b04042146cb3875c6635f0aa1
MD5 871f2c93e6fc4ac68d64ea7eddabe240
BLAKE2b-256 682683cc05c66a64f2824536171a804f527a32e2f3baecbd7de58fa83574c5e4

See more details on using hashes here.

File details

Details for the file ssm_simulators-0.12.4-cp311-cp311-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for ssm_simulators-0.12.4-cp311-cp311-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 3a5fb7a50bd9e4723dbd6aea607297b7301bd9cc6dd6a9317f2f12e81df4a93b
MD5 e7e8fd4dac0314557fc2ef786eab4cad
BLAKE2b-256 9383c2170b8af7598127e5c599f707d7e0ea52abe680eb3f8566edf84591c980

See more details on using hashes here.

File details

Details for the file ssm_simulators-0.12.4-cp311-cp311-macosx_10_9_x86_64.whl.

File metadata

File hashes

Hashes for ssm_simulators-0.12.4-cp311-cp311-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 076dcaf885d04a02ba7b74d8094909532a0538104b523ddbab37d25a76ef7a5b
MD5 1de8646340ad9b190b3b7500caca213a
BLAKE2b-256 f6802058ca66744fc0683a1068ce5e5c8c90c3bb14df2b17ca40c5d9aec9ec08

See more details on using hashes here.

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