Skip to main content

A language for synthesizing randomized experimental designs

Project description

SweetPea

Build Status
typecheck
acceptance (fast)
acceptance (slow)
package

SweetPea is a domain-specific language for specifying factorial experimental designs and synthesizing trial sequences from those design specifications. An explanation of factorial experimental designs and how to build and manipulate them in SweetPea can be found in the SweetPea Guide.

See also the paper describing SweetPea, but beware that the API has changed. The main changes are replacing most functions with classes, changing some function names, and simplifying the organization to just a sweetpea module that exports everything.

SweetPea includes a synthesizer to generate sequences of trials that satisfy the design's constraints. The goal is to generate sequences that are unbiased: every possible sequence of trials that satifies the design constraints is equally likely to be generated, which avoids correlations that are not part of the experiment's definition. With current technologies, SweetPea achieves that goal for designs with either simple constraints or a small number of combinations. SweetPea can also generate samples that seem uniform in practice for medium-sized designs, although without a formal guarantee. Generating unbiased samples for large designs remains an area of active research and development.

For designs that do not involve constraints that span trials within a sequence, SweetPea can directly sample with combinatoric techniques. Realistic designs often involve transition constraints or other cross-trial constraints, however. For those cases, SweetPea's primary sampling strategy compiles an experiment design into a boolean formula; compilation ensures a 1-to-1 correspondence between distinct satisfying assignments to the boolean formula and distinct trial sequences, so that uniformly sampling solutions to the boolean formula imples a unform sample of trial sequences. SweetPea uses CMSGen and UniGen to sample solutions to the boolean formula. CMSGen generates samples that appear to be well distributed in practice, but CMSGen lacks a formal guarantee of uniformity. UniGen provides statistical guarantees that the solutions it finds are approximately uniformly probable, but its approach is tractable only for the smallest designs that are expressed with SweetPea.

Dependencies

SweetPea requires Python 3.9 or later.

Installation

There are two ways to install SweetPea: from the Python Package Index (PyPI), or from source.

Installing from PyPI

SweetPea can be installed from PyPI via pip:

$ pip install sweetpea

Installing from Source

Clone this repository, install SweetPea's dependencies, and install SweetPea itself:

$ git clone https://github.com/sweetpea-org/sweetpea-py.git
$ cd sweetpea-py
$ pip install -r requirements.txt
$ pip install .

:exclamation: Important!

The pip install . command installs SweetPea locally, but it will not automatically check for updates. If you intend to manually update your local copy of SweetPea, you should instead do pip install -e . to tell pip to use the source dynamically.


Examples

There are example programs in the example_programs directory, and there is a detailed explanation of how to use SweetPea in the SweetPea Guide.

API Documentation

The SweetPea API is documented in the API section of the SweetPea Guide.

Contributing

Information on how to contribute to SweetPea's development can be found in the Contributing section of the SweetPea Guide.

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.2.12.tar.gz (159.3 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.2.12-py3-none-any.whl (197.4 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: sweetpea-0.2.12.tar.gz
  • Upload date:
  • Size: 159.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.9.6

File hashes

Hashes for sweetpea-0.2.12.tar.gz
Algorithm Hash digest
SHA256 652000dea43b596b1d52d9fea9e830c96d7359b3c6ccfaf0345dd5e376b4d19a
MD5 ed88a74b6502cbea14a89f46d6fa7dbb
BLAKE2b-256 02ec1de9f0ecc1fe135c5414c2388911f4e599298d7803c9c7d114a84e3a8347

See more details on using hashes here.

File details

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

File metadata

  • Download URL: sweetpea-0.2.12-py3-none-any.whl
  • Upload date:
  • Size: 197.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.9.6

File hashes

Hashes for sweetpea-0.2.12-py3-none-any.whl
Algorithm Hash digest
SHA256 e2c0cbb80f724072d4d21f341f9dcc2353b2c179f6a6d76093690f42a5df3180
MD5 41f8cb12c33825b5600190b75981e086
BLAKE2b-256 a4be8472d39638e68a933148dffedde1965e713d28cce9e72fd5f4c30a70be83

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