Skip to main content

A language for synthesizing randomized experimental designs

Project description

SweetPea
========

[![Build Status](https://travis-ci.org/sweetpea-org/sweetpea-py.svg?branch=master)](https://travis-ci.org/sweetpea-org/sweetpea-py)

SweetPea is a language for declaratively specifying randomized experimental designs, and a runtime for synthesizing trial sequences generated from the design specification; this prototype that is targeted at psychology and neuroscience experiments.

An experimental design is a description of experimental factors, relationships between factors, sequential constraints, and how to map those factors onto a sequence of trials. The reliability and validity of experimental results heavily relies on rigorous experimental design.

SweetPea provides a high-level interface to declaratively describe an experimental design, and a low-level synthesizer to generate unbiased sequences of trials given satisfiable constraints. SweetPea samples sequences of trials by compiling experimental designs into Boolean logic, which are then passed to a SAT-sampler. The SAT-sampler [Unigen](https://bitbucket.org/kuldeepmeel/unigen) provides statistical guarantees that the solutions it finds are approximately uniformly probable in the space of all valid solutions. This means that while producing sequences of trials that are perfectly unbiased is intractable, we do the next best thing-- produce sequences that are approximately unbiased.


## Disclaimer!

This project is at an early stage, and likely to change: it isn't yet ready for real-world useage. Please don't rely on any of this code!


## Usage

SweetPea also depends on [Docker][1] being installed and running on your machine.

Intstall with `pip`:

```
pip install sweetpea
```

Example:

```python
import operator as op

from sweetpea import *

color = Factor("color", ["red", "blue"])
text = Factor("text", ["red", "blue"])

conLevel = DerivedLevel("con", WithinTrial(op.eq, [color, text]))
incLevel = DerivedLevel("inc", WithinTrial(op.ne, [color, text]))
conFactor = Factor("congruent?", [conLevel, incLevel])

design = [color, text, conFactor]
crossing = [color, text]

k = 1
constraints = [AtMostKInARow(k, ("congruent?", "con"))]

block = fully_cross_block(design, crossing, constraints)

experiments = synthesize_trials(block)

print_experiments(block, experiments)
```

[1]: https://www.docker.com/



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

sweetpea-0.0.35.tar.gz (52.9 kB view details)

Uploaded Source

Built Distribution

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

sweetpea-0.0.35-py3-none-any.whl (76.7 kB view details)

Uploaded Python 3

File details

Details for the file sweetpea-0.0.35.tar.gz.

File metadata

  • Download URL: sweetpea-0.0.35.tar.gz
  • Upload date:
  • Size: 52.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.11.0 pkginfo/1.4.2 requests/2.21.0 setuptools/40.7.1 requests-toolbelt/0.8.0 tqdm/4.26.0 CPython/3.6.7

File hashes

Hashes for sweetpea-0.0.35.tar.gz
Algorithm Hash digest
SHA256 d1cc98cb94aa69b1e04b5c8599314c8651da24fcbbfdb646203e8af53609c8c7
MD5 aa7a4a16ab54811ce19adbab30b5f9c0
BLAKE2b-256 8c2205813c34c52c4b3614b7bc3d5ff9fea12e620793a511cb062557c64b56a0

See more details on using hashes here.

File details

Details for the file sweetpea-0.0.35-py3-none-any.whl.

File metadata

  • Download URL: sweetpea-0.0.35-py3-none-any.whl
  • Upload date:
  • Size: 76.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.11.0 pkginfo/1.4.2 requests/2.21.0 setuptools/40.7.1 requests-toolbelt/0.8.0 tqdm/4.26.0 CPython/3.6.7

File hashes

Hashes for sweetpea-0.0.35-py3-none-any.whl
Algorithm Hash digest
SHA256 78a2f144d7890b832512b71bdd6047932b55ff42a0c44241b2946b66cf8d8dd4
MD5 52369bf75f199ab2f72f035cb98d8a66
BLAKE2b-256 a887cbd9efd2a36a53dc00c05f8e4faa44ab7e61a24acc5b031542a5ff3af201

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