Skip to main content

psp-torch

psp: parameter space partitioning

Parameter space partitioning MCMC for global model evaluation (Pitt, Kim, Navarro & Myung, 2006), in PyTorch. The methods implemented here were designed to support the type of analyses done by Dome & Wills (2025).

Install

pip install git+https://github.com/lenarddome/psp-torch

The library needs only torch and numpy. The notebooks and psp.read_saved() need the notebooks extra (pandas, matplotlib, jupyter, ipywidgets, scikit-learn); the fast-save extra (pyarrow) speeds up save=True.

For development, the project is managed with uv:

uv sync                                   # CUDA 12.8 build of torch, dev tools and notebook extras
uv sync --no-group cu128 --group cpu      # CPU-only build of torch instead
uv run pytest
uv run ruff check psp tests && uv run mypy psp

Citing psp-torch

If you are using psp-torch in your work, please cite the following papers:

@article{dome2025gdistance,
  title = {g-{{Distance}}: {{On}} the Comparison of Model and Human Heterogeneity.},
  author = {Dome, Lenard and Wills, Andy J.},
  year = 2025,
  journal = {Psychological Review},
  volume = {132},
  number = {3},
  pages = {632--655},
  publisher = {American Psychological Association},
  doi = {10.1037/rev0000550},
  langid = {english},
} 

@article{pitt2006global,
  title = {Global Model Analysis by Parameter Space Partitioning.},
  author = {Pitt, Mark A. and Kim, Woojae and Navarro, Daniel J. and Myung, Jay I.},
  year = 2006,
  journal = {Psychological Review},
  volume = {113},
  number = {1},
  pages = {57--83},
  publisher = {American Psychological Association},
  doi = {10.1037/0033-295X.113.1.57},
}

Quick start

A model of risky choice with two parameters, and the pattern of choices it makes on four bets (the tutorial explains the model):

import torch
from psp import PSP
from psp.models import prospect

torch.manual_seed(2026)
control = {
    "lower": [0.2, 0.3],
    "upper": [1.0, 1.2],
    "init": torch.stack([torch.rand(5) * 0.8 + 0.2, torch.rand(5) * 0.9 + 0.3], dim=1),
    "radius": 0.5,
    "population": 200,
    "iterations": 30000,
    "parameter_names": ["alpha", "gamma"],
    "dimensionality": 4,
    "responses": 4,
}
result = PSP(prospect.model, prospect.discretize, control, quiet=True)
for pattern, count in zip(result.ordinal_patterns, result.ordinal_counts):
    print(f"{int(count):>5}  {prospect.describe(pattern)}")

prospect.model maps a (n, 2) tensor of parameter sets to a (n, 4) tensor of predictions, and prospect.discretize maps those to (n, 4, 4) ordinal patterns. Two parameter sets belong to the same region when their patterns are identical.

Documentation

To learn how to use psp-torch, and more about the type of analyses it can support, please visit the package documentation here.

License

AGPL-3.0, see LICENSE.

Metadata

Release files for psp-torch 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 psp-torch 0.2.1
File Size Uploaded Provenance
psp_torch-0.2.1.tar.gz 308.4 kB With provenance Details

Built distribution (wheel)

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

Total release size: 597.2 kB

Release files / psp_torch-0.2.1.tar.gz

Download URL psp_torch-0.2.1.tar.gz
Size 308.4 kB
Tags Source
SHA-256 checksum
How to use checksums
448f2fb13f0c6aae7011ca56c6608f3b0e9396080854d52984d0b3ae4c460eac
BLAKE2b-256 checksum
How to use checksums
8b815fbf555c6bcbd2dcdcdf6f6cfc96dcba9cf242f64a31416ba9030baf752a
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

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 20, 2026.

Transparency log

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

Download URL psp_torch-0.2.1-py3-none-any.whl
Size 288.9 kB
Tags Python 3
SHA-256 checksum
How to use checksums
430934f9c5e014867c66fa64a9bc21a79f0411dd2f2343183223643db25a455c
BLAKE2b-256 checksum
How to use checksums
64c14a9c283f1787c7aa3e485298714c6d163326646ad541c63e17689b619e24
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

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 20, 2026.

Transparency log

Security for psp-torch 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

All 2 files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for psp_torch-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 20, 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.

Release history Release notifications | RSS feed

This release

0.2.1 This release

2 release files Full provenance

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