Skip to main content
Pre-release

This release is a pre-release and may not be stable for production use.

A minimal Python Protocol for data-generating processes (DGPs).

What this is

A Protocol (DataGeneratingProcess) with two members – data (a frozen property returning the observed realization) and draw(size=..., *, rng=...) (a method returning a fresh realization) – plus a small set of composition primitives (TwoStageDGP, with_data) and thin convenience wrappers (EmpiricalDGP, ParametricDGP) for working with DGPs as first-class objects.

The package is not a library of working DGPs. Concrete DGPs live in consumer packages – e.g.
ManifoldGMM ships its own moment-side DGPs. The role of DGP_Protocol is to define the contract that lets such consumers interoperate.

Conceptual lineage

The Protocol promotes the stand-in distribution from Manski's analog estimation framework (Manski 1988, Analog Estimation Methods in Econometrics) to a first-class Python object. In that framework, an estimator is defined by a population functional plus a sample-based stand-in for the population; DataGeneratingProcess is that stand-in. Different stand-ins yield different analog estimators:

  • The empirical distribution -> nonparametric plug-in estimators.
  • A parametric family fitted to the data -> MLE-style estimators.
  • A bootstrap distribution -> bootstrap inference.
  • A null-imposed restriction -> constrained estimators.

Installation

pip install DGP_Protocol

The import path is PEP-8 lowercase:

from dgp_protocol import DataGeneratingProcess, EmpiricalDGP, TwoStageDGP

Minimal example

import numpy as np
from dgp_protocol import EmpiricalDGP

data = np.random.default_rng(0).standard_normal(size=(100, 3))

# The DGP owns its own RNG.  Pass `seed` for reproducibility;
# `draw()` itself takes no `rng` argument.
dgp = EmpiricalDGP(observation=data, seed=1)
print(dgp.data.shape)                  # (100, 3) -- the frozen realization
print(dgp.draw().shape)                # (100, 3) -- a fresh bootstrap resample

# Rebind to a different realization while keeping the distributional
# structure.  The child gets an independent (spawned) Generator.
fresh = dgp.with_data(np.random.default_rng(2).standard_normal(size=(50, 3)))
print(fresh.data.shape)                # (50, 3)

For more substantial examples – parametric DGPs, two-stage composition (hierarchical sampling), cluster-block bootstrap – see the test suite under tests/.

Design

The design is intentionally minimal: data + draw are the only required members. Composition primitives (TwoStageDGP, with_data) take DGPs and return DGPs without expanding the Protocol.

The design note that motivated this package lives in the sibling ManifoldGMM repo at docs/design/dgp.org – DGPProtocol was extracted from that design conversation. See also AGENTS.md for the package's scope discipline and the list of intentionally deferred features.

How to cite

If you use DGPProtocol in academic work, please cite it. The repository's CITATION.cff is recognised by GitHub and provides one-click citation export in APA, BibTeX, and other formats from the repo's main page.

A BibTeX entry suitable for paper drafts:

@software{ligon_dgp_protocol_2026,
  author    = {Ligon, Ethan},
  title     = {DGP\_Protocol: A Protocol for data-generating processes},
  year      = {2026},
  publisher = {GitHub},
  url       = {https://github.com/ligon/DGP_Protocol},
  version   = {0.1.0a0},
  license   = {BSD-3-Clause},
}

License

BSD 3-Clause (BSD-3-Clause). See the LICENSE file at the root of this repository. In short: permissive use including commercial, modification, and redistribution; preserve the copyright notice and license text in redistributions; no use of the author's name to endorse derived products.

Author

Ethan Ligon, UC Berkeley.

Metadata

Release files for DGP-Protocol 0.1.0a0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for DGP-Protocol 0.1.0a0
File Size Uploaded Provenance Actions
dgp_protocol-0.1.0a0.tar.gz 26.8 kB With provenance Details for dgp_protocol-0.1.0a0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for DGP-Protocol 0.1.0a0
File Interpreter ABI Platform Actions
dgp_protocol-0.1.0a0-py3-none-any.whl Python 3 none any Details for dgp_protocol-0.1.0a0-py3-none-any.whl

Total release size: 60.3 kB

Release files / dgp_protocol-0.1.0a0.tar.gz

Download URL dgp_protocol-0.1.0a0.tar.gz
Size 26.8 kB
Tags Source
SHA-256 checksum
How to use checksums
be16c902587df6df56f9a61efe4ab49850b65f3f3c66fd9ff40f7d693402ceb3
BLAKE2b-256 checksum
How to use checksums
4dee2d4b668ea14de60c53e39b77335165dc51e92184c32cda2dc23a0bc12f6d
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.12

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 May 27, 2026.

Transparency log

Release files / dgp_protocol-0.1.0a0-py3-none-any.whl

Download URL dgp_protocol-0.1.0a0-py3-none-any.whl
Size 33.5 kB
Tags Python 3
SHA-256 checksum
How to use checksums
263600c6f7c1c069ef05f8a15ceb2c79c575ba6d330a8751ce1af03f649ec165
BLAKE2b-256 checksum
How to use checksums
5509f103af7e7cde4b8d3660abe4019ad647e97b4b18b68be9333d39550f20c4
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.12

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 May 27, 2026.

Transparency log

Security for DGP-Protocol 0.1.0a0

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 dgp_protocol-0.1.0a0.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 May 27, 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.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release
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