Skip to main content

Generalized drift diffusion modeling for Python

Project description

PyDDM - Generalized drift-diffusion models for Python

Overview

PyDDM is a simulator and modeling framework for generalized drift-diffusion models (DDM). Key features include:

  • Fast solutions for drift-diffusion models (DDM) and generalized drift-diffusion models (GDDM)
  • Easy and flexible syntax for building models
  • Arbitrary Python functions define parameters for drift rate, noise, bounds, non-decision time, and starting position
  • Graphical interface for exploring new models
  • Multiprocessor support

See the documentation, FAQs, or tutorial for more information. If you want to try it out before installing, visit the interactive online demo. See the Github Forums for help from the PyDDM community. You can also sign up for release announcements by email (a couple emails per year).

Examples

To simulate a simple DDM:

from pyddm import gddm
import matplotlib.pyplot as plt
model = gddm(drift=2, noise=1.5, bound=1.3, starting_position=.1, nondecision=.1)
plt.plot(model.solve().pdf("upper_bound"))

To fit data to a simple DDM:

import pyddm, pandas
model = pyddm.gddm(drift="driftrate", noise=1, bound="B", starting_position="x0", nondecision="ndt",
                   parameters={"driftrate": (-1, 1), 
                               "B": (.5, 2),
                               "x0": (-.5, .5),
                               "ndt": (0, .5)})
data = pandas.from_csv("your_data_here.csv")
sample = pyddm.Sample.from_pandas_dataframe(df, rt_column_name="rt", choice_column_name="correct")
model.fit(sample)

To use PyDDM's GUI to visualize a complex model with leaky integration, a constant drift rate, exponentially collapsing bounds, and a variable starting position:

import pyddm
import pyddm.plot
import numpy as np
model = pyddm.gddm(drift=lambda x,leak,driftrate : driftrate - x*leak,
                   bound=lambda t,initial_B,collapse_rate : initial_B * np.exp(-collapse_rate*t),
                   starting_position="x0",
                   parameters={"leak": (0, 2),
                               "driftrate": (-3, 3),
                               "initial_B": (.5, 1.5),
                               "collapse_rate": (0, 10),
                               "x0": (-.9, .9)})

pyddm.plot.model_gui(model) # If not using a Jupyter notebook, or...
pyddm.plot.model_gui_jupyter(model) # If using a Jupyter notebook

PyDDM Model GUI

Installation

Normally, you can install with:

$ pip install pyddm

If you are in a shared environment (e.g. a cluster), install with:

$ pip install pyddm --user

If installing from source, download the source code, extract, and do:

$ python3 setup.py install

System requirements

  • Python 3.6 or above
  • Numpy version 1.9.2 or higher
  • Scipy version 0.16.0 or higher
  • Matplotlib
  • Paranoid Scientist
  • Pathos (optional, for multiprocessing support)
  • To install from source, you will need a C compiler (If you don't already have one, the easiest way to install one may be by installing Cython.) This is not necessary if installing from pip.

Contact

For help on using PyDDM, see the Github Forums.

Please report bugs to https://github.com/mwshinn/pyddm/issues. This includes any problems with the documentation. Pull Requests for bugs are greatly appreciated.

Feature requests are currently not being accepted due to limited resources. If you implement a new feature in PyDDM, please do the following before submitting a Pull Request on Github:

  • Make sure your code is clean and well commented
  • If appropriate, update the official documentation in the docs/ directory
  • Ensure there are Paranoid Scientist verification conditions to your code
  • Write unit tests and optionally integration tests for your new feature (runtests.sh)
  • Ensure all existing tests pass

For all other questions or comments, contact m.shinn@ucl.ac.uk.

License

All code is available under the MIT license. See LICENSE.txt for more information.

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

pyddm-0.8.1.tar.gz (85.4 kB view hashes)

Uploaded Source

Built Distributions

pyddm-0.8.1-cp311-cp311-win_amd64.whl (105.8 kB view hashes)

Uploaded CPython 3.11 Windows x86-64

pyddm-0.8.1-cp311-cp311-win32.whl (103.5 kB view hashes)

Uploaded CPython 3.11 Windows x86

pyddm-0.8.1-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (117.7 kB view hashes)

Uploaded CPython 3.11 manylinux: glibc 2.17+ x86-64

pyddm-0.8.1-cp311-cp311-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl (116.4 kB view hashes)

Uploaded CPython 3.11 manylinux: glibc 2.17+ i686 manylinux: glibc 2.5+ i686

pyddm-0.8.1-cp311-cp311-macosx_11_0_arm64.whl (101.4 kB view hashes)

Uploaded CPython 3.11 macOS 11.0+ ARM64

pyddm-0.8.1-cp311-cp311-macosx_10_9_x86_64.whl (102.5 kB view hashes)

Uploaded CPython 3.11 macOS 10.9+ x86-64

pyddm-0.8.1-cp310-cp310-win_amd64.whl (105.8 kB view hashes)

Uploaded CPython 3.10 Windows x86-64

pyddm-0.8.1-cp310-cp310-win32.whl (103.5 kB view hashes)

Uploaded CPython 3.10 Windows x86

pyddm-0.8.1-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (117.6 kB view hashes)

Uploaded CPython 3.10 manylinux: glibc 2.17+ x86-64

pyddm-0.8.1-cp310-cp310-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl (116.3 kB view hashes)

Uploaded CPython 3.10 manylinux: glibc 2.17+ i686 manylinux: glibc 2.5+ i686

pyddm-0.8.1-cp310-cp310-macosx_11_0_arm64.whl (101.4 kB view hashes)

Uploaded CPython 3.10 macOS 11.0+ ARM64

pyddm-0.8.1-cp310-cp310-macosx_10_9_x86_64.whl (102.5 kB view hashes)

Uploaded CPython 3.10 macOS 10.9+ x86-64

pyddm-0.8.1-cp39-cp39-win_amd64.whl (105.8 kB view hashes)

Uploaded CPython 3.9 Windows x86-64

pyddm-0.8.1-cp39-cp39-win32.whl (103.5 kB view hashes)

Uploaded CPython 3.9 Windows x86

pyddm-0.8.1-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (117.5 kB view hashes)

Uploaded CPython 3.9 manylinux: glibc 2.17+ x86-64

pyddm-0.8.1-cp39-cp39-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl (116.2 kB view hashes)

Uploaded CPython 3.9 manylinux: glibc 2.17+ i686 manylinux: glibc 2.5+ i686

pyddm-0.8.1-cp39-cp39-macosx_11_0_arm64.whl (101.4 kB view hashes)

Uploaded CPython 3.9 macOS 11.0+ ARM64

pyddm-0.8.1-cp39-cp39-macosx_10_9_x86_64.whl (102.5 kB view hashes)

Uploaded CPython 3.9 macOS 10.9+ x86-64

pyddm-0.8.1-cp38-cp38-win_amd64.whl (105.6 kB view hashes)

Uploaded CPython 3.8 Windows x86-64

pyddm-0.8.1-cp38-cp38-win32.whl (103.3 kB view hashes)

Uploaded CPython 3.8 Windows x86

pyddm-0.8.1-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (119.1 kB view hashes)

Uploaded CPython 3.8 manylinux: glibc 2.17+ x86-64

pyddm-0.8.1-cp38-cp38-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl (117.9 kB view hashes)

Uploaded CPython 3.8 manylinux: glibc 2.17+ i686 manylinux: glibc 2.5+ i686

pyddm-0.8.1-cp38-cp38-macosx_11_0_arm64.whl (101.1 kB view hashes)

Uploaded CPython 3.8 macOS 11.0+ ARM64

pyddm-0.8.1-cp38-cp38-macosx_10_9_x86_64.whl (102.2 kB view hashes)

Uploaded CPython 3.8 macOS 10.9+ x86-64

pyddm-0.8.1-cp37-cp37m-win_amd64.whl (105.6 kB view hashes)

Uploaded CPython 3.7m Windows x86-64

pyddm-0.8.1-cp37-cp37m-win32.whl (103.3 kB view hashes)

Uploaded CPython 3.7m Windows x86

pyddm-0.8.1-cp37-cp37m-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (118.6 kB view hashes)

Uploaded CPython 3.7m manylinux: glibc 2.17+ x86-64

pyddm-0.8.1-cp37-cp37m-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl (117.4 kB view hashes)

Uploaded CPython 3.7m manylinux: glibc 2.17+ i686 manylinux: glibc 2.5+ i686

pyddm-0.8.1-cp37-cp37m-macosx_10_9_x86_64.whl (102.2 kB view hashes)

Uploaded CPython 3.7m macOS 10.9+ x86-64

pyddm-0.8.1-cp36-cp36m-win_amd64.whl (105.9 kB view hashes)

Uploaded CPython 3.6m Windows x86-64

pyddm-0.8.1-cp36-cp36m-win32.whl (103.5 kB view hashes)

Uploaded CPython 3.6m Windows x86

pyddm-0.8.1-cp36-cp36m-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (118.6 kB view hashes)

Uploaded CPython 3.6m manylinux: glibc 2.17+ x86-64

pyddm-0.8.1-cp36-cp36m-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl (117.5 kB view hashes)

Uploaded CPython 3.6m manylinux: glibc 2.17+ i686 manylinux: glibc 2.5+ i686

pyddm-0.8.1-cp36-cp36m-macosx_10_9_x86_64.whl (102.2 kB view hashes)

Uploaded CPython 3.6m macOS 10.9+ x86-64

Supported by

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