Metadata-Version: 2.4
Name: product-monte-carlo
Version: 0.1.1
Summary: Product Monte Carlo for distributed and federated inference
Author: Pietro Carlotti
License-Expression: MIT
Project-URL: Homepage, https://github.com/PietroCarlotti/PMC_AISTATS
Project-URL: Source, https://github.com/PietroCarlotti/PMC_AISTATS
Keywords: Bayesian inference,distributed inference,federated learning,Monte Carlo,PyTorch
Classifier: Development Status :: 3 - Alpha
Classifier: Intended Audience :: Science/Research
Classifier: Operating System :: OS Independent
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Topic :: Scientific/Engineering
Requires-Python: >=3.10
Description-Content-Type: text/markdown
License-File: LICENSE
Requires-Dist: torch<3,>=2.1
Provides-Extra: test
Requires-Dist: pytest; extra == "test"
Requires-Dist: ruff; extra == "test"
Dynamic: license-file

# Product Monte Carlo (PMC)

PMC estimates expectations under a product of densities using independent samples from each component, without evaluating the densities. The package lets you choose a consensus function, a discrepancy function, and a regressor.

## Install

```bash
pip install product-monte-carlo
```

PMC requires Python 3.10 or newer and PyTorch. Import it as `pmc`.

## Quick example

```python
import torch

from pmc import AnchoredDifferences, Mean, OLS, PMC

samples = torch.randn(1_000, 2, 1)  # draws x components x dimensions

estimator = PMC(
    consensus=Mean(),
    discrepancy=AnchoredDifferences(),
    h=lambda x: x,
    regressor=OLS(),
)
estimate = estimator.estimate(samples)
print(estimate)
```

For the research code and experiments, see the [GitHub repository](https://github.com/PietroCarlotti/PMC_AISTATS).
