Skip to main content

A minimal preconditioned Crank-Nicolson MCMC sampler

Project description

minipcn

DOI

A minimal implementation of preconditioned Crank-Nicolson MCMC sampling.

Installation

minipcn can be installed using from PyPI using pip:

pip install minipcn

Usage

The basic usage is:

from minipcn import Sampler
import numpy as np

log_prob_fn = ...    # Log-probability function - must be vectorized
dims = ...    # The number of dimensions
rng = np.random.default_rng(42)

sampler = Sampler(
    log_prob_fn=log_prob_fn,
    dims=dims,
    step_fn="pcn",    # Or tpcn
    rng=rng,
)

# Generate initial samples
x0 = rng.randn(size=(100, dims))

# Run the sampler
chain, history = sampler.run(x0, n_steps=500)

For a complete example, see the examples directory.

Citing minipcn

If you use minipcn in your work, please cite our DOI

If using the tpcn kernel, please also cite Grumitt et al

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

minipcn-0.1.1.tar.gz (12.4 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

minipcn-0.1.1-py3-none-any.whl (8.4 kB view details)

Uploaded Python 3

File details

Details for the file minipcn-0.1.1.tar.gz.

File metadata

  • Download URL: minipcn-0.1.1.tar.gz
  • Upload date:
  • Size: 12.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for minipcn-0.1.1.tar.gz
Algorithm Hash digest
SHA256 e7734fd357535cfd86e4fe38d56b6d99fbb5ac99c23767e90ebe99159e931d90
MD5 6573fadf0fe624306b73e8d765de55b2
BLAKE2b-256 50b9a5240f74e85f2b328794a7e680bfc3ae7e57962a4b73724a1804a98c5c62

See more details on using hashes here.

Provenance

The following attestation bundles were made for minipcn-0.1.1.tar.gz:

Publisher: publish.yml on mj-will/minipcn

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file minipcn-0.1.1-py3-none-any.whl.

File metadata

  • Download URL: minipcn-0.1.1-py3-none-any.whl
  • Upload date:
  • Size: 8.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for minipcn-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 c89fd07d7ea8094f4df060fb88fbba23ddf368fd91fd57f9dcee25eb345b0838
MD5 0703b055a1c4c5c38e722ef014b6cae8
BLAKE2b-256 ec657fb5603f9075f18061fc68444f59302b259381ab10146211b291e2ad94b5

See more details on using hashes here.

Provenance

The following attestation bundles were made for minipcn-0.1.1-py3-none-any.whl:

Publisher: publish.yml on mj-will/minipcn

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

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