mcsamplers
Monte-Carlo stochastic samplers for gravitational-wave parameter estimation:
nested sampling and MCMC, built around a small Model base class that you
subclass with your own likelihood.
pip install mcsamplers
Requires Python 3.11+.
The Model contract
Everything here works against one abstraction. Subclass Model, implement
evaluate_logliklihood, and the reduced-coordinate machinery comes with it:
the samplers explore the unit cube [0, 1]^ndim, and Model maps those
points onto your physical priors before calling you.
import numpy as np
from mcsamplers.model import Model
class Gaussian(Model):
def evaluate_logliklihood(self, parameters):
return -0.5 * float(np.sum(np.asarray(parameters) ** 2))
model = Gaussian(
xdata=np.linspace(0, 1, 64),
ydata=np.zeros(64),
initial_guess=[0.5, 0.5],
parameter_priors_dict={"a": [0.0, 2.0], "b": [-1.0, 1.0]},
)
# Unit cube in, physical parameters out: (0.5, 0.5) -> (1.0, 0.0)
model.evaluate_logliklihood_reduced(np.array([0.5, 0.5]))
Priors are uniform boxes given as {name: [min, max]}. Model also supplies
evaluate_liklihood, ln_prior_probability, pushforward_samples and the
pickle round trip the samplers use for checkpointing.
Nested sampling
from mcsamplers.nested.sampler import NestedSampler
sampler = NestedSampler(n_live=500, n_dim=2, n_iter=5000, Model=model)
sampler.run()
samples = sampler.posterior_samples
log_z = sampler.logevidence
New live points are drawn according to random_sample_method, one of
prior, mcmc, random-distance or relative-centroid. Runs can be
checkpointed and resumed with restart=True and checkpoint_time_stamps.
MCMC
mcsamplers.markov_chain.yumcee is a Metropolis–Hastings sampler with
multiple walkers:
from mcsamplers.markov_chain.yumcee import yumcee_run
samples = yumcee_run(loglik, iguess, ndim, nwalkers, nsteps, prop_sigma)
yumcee_p is a parallel variant intended to run across nodes, and
yumcee_utils holds autocorrelation, corner-plot and sample-statistics
helpers.
Tests
pip install mcsamplers[opt]
pytest --pyargs mcsamplers.tests
Status and caveats
This is research code — used in anger, but not hardened for general use. The
test suite pins the Model contract, not sampling correctness: the samplers
themselves have no numerical regression tests.
Licence
MIT. See LICENSE.
Metadata
Release files for mcsamplers 2026.9.4
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 |
|---|---|---|---|---|
| mcsamplers-2026.9.4.tar.gz | 312.7 kB | Without provenance | Details for mcsamplers-2026.9.4.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| mcsamplers-2026.9.4-py3-none-any.whl | Python 3 | none | any | Details for mcsamplers-2026.9.4-py3-none-any.whl |
Total release size: 343.6 kB
Release files / mcsamplers-2026.9.4.tar.gz
| Download URL | mcsamplers-2026.9.4.tar.gz |
|---|---|
| Size | 312.7 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
6c0131d29b7e25f7f9a71a205e9e620454061f76853716a8930c1bac5932b53e
|
|
BLAKE2b-256 checksum How to use checksums |
37fa61401f6976aee725d8928f3da43e87b769c5fe66caecdf3ca9d98eeaf309
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.12.14
|
Release files / mcsamplers-2026.9.4-py3-none-any.whl
| Download URL | mcsamplers-2026.9.4-py3-none-any.whl |
|---|---|
| Size | 31.0 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
32ab00b5a61e1df8d32f7ee57d2ecc20a2a11aac25ca2a9a556082411ce2a7a5
|
|
BLAKE2b-256 checksum How to use checksums |
24e81d100afa60785b916efe430134a2fc27f41b3a458fa562e6d4f0541d9fac
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.12.14
|
Security for mcsamplers 2026.9.4
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.
No provenance found
None of the files in this release were uploaded with provenance metadata.
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.