Product Monte Carlo (PMC)
PMC estimates expectations under a product of densities. To see how, consider the following setup.
Suppose you can draw samples independently from $K$ distributions on $\mathcal X\subseteq\mathbb R^p$:
We define the product distribution $\pi^\star$ as follows:
Given a function $h:\mathcal X\to\mathbb R$, we wish to compute its expectation under $\pi^\star$:
We call a function $c:\mathcal X^K\to\mathcal X$ a consensus function if
We call a function $d:\mathcal X^K\to\mathbb R^m$ a discrepancy function if, for all $x_1,\ldots,x_K\in\mathcal X$,
Let $C=c(X_1,\ldots,X_K)$ and $D=d(X_1,\ldots,X_K)$. Then, under suitable regularity conditions, we have that
PMC then works as follows:
- Draw $S$ independent samples per distribution.
- For each set of $K$ draws, compute its consensus $C$ and discrepancy $D$.
- Fit a regressor to predict $h(C)$ from $D$.
- Estimate the target expectation by evaluating the fitted regressor at $D=\mathbf 0_m$.
Install
To install PMC from PyPI, run:
pip install product-monte-carlo
Example
The example below shows how to estimate an expectation with PMC.
# Import PyTorch and PMC classes
import torch
from pmc import AnchoredDifferences, Mean, OLS, PMC
# Draw S = 1,000 samples from K = 2 univariate standard Gaussian distributions (p = 1)
samples = torch.randn(1_000, 2, 1)
# Configure PMC to estimate the mean under the product distribution
PMC_estimator = PMC(
consensus=Mean(),
discrepancy=AnchoredDifferences(),
h=lambda x: x,
regressor=OLS(),
)
# Compute and print the resulting estimate
PMC_estimate = PMC_estimator.estimate(samples)
print(PMC_estimate)
Metadata
Release files for product-monte-carlo 0.1.12
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| product_monte_carlo-0.1.12.tar.gz | 12.9 kB | With provenance | Details for product_monte_carlo-0.1.12.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| product_monte_carlo-0.1.12-py3-none-any.whl | Python 3 | none | any | Details for product_monte_carlo-0.1.12-py3-none-any.whl |
Total release size: 27.0 kB
Release files / product_monte_carlo-0.1.12.tar.gz
| Download URL | product_monte_carlo-0.1.12.tar.gz |
|---|---|
| Size | 12.9 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
5e21361c071ee534e970ca70ad179c9dd626ec5dfaa45828255d719448b3c317
|
|
BLAKE2b-256 checksum How to use checksums |
ccbaaecee81846a9978ccf56fd3e67388c30cf3824289602db0fd6d90bfc5727
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
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 Nov 3, 2026.
Transparency logRelease files / product_monte_carlo-0.1.12-py3-none-any.whl
| Download URL | product_monte_carlo-0.1.12-py3-none-any.whl |
|---|---|
| Size | 14.1 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
e59b15a0f14cc73dea0b937a175526ef83081442b8e95bf33ddcb305446ea16e
|
|
BLAKE2b-256 checksum How to use checksums |
a63efb333042f2d92549cbdd29b10ce4ae8821a9e32e6c284ccf6ff023038ee8
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
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 Nov 3, 2026.
Transparency logSecurity for product-monte-carlo 0.1.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.
Full provenance
All 2 files in this release have been uploaded with provenance metadata.
Attestation for product_monte_carlo-0.1.12.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 Nov 3, 2026.
Transparency logA 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.