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.0.tar.gz (12.3 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.0-py3-none-any.whl (8.3 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: minipcn-0.1.0.tar.gz
  • Upload date:
  • Size: 12.3 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.0.tar.gz
Algorithm Hash digest
SHA256 7a57f823f46615e9a81635774411847d0da39f4d3e7cd32d29613a15b6cdc0aa
MD5 1713e2c2d56013642d7afc735fcbbdb4
BLAKE2b-256 b39b138e97b28493b80d6ef87d7428067f7c14a6a559e6f6086264b6401c6511

See more details on using hashes here.

Provenance

The following attestation bundles were made for minipcn-0.1.0.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.0-py3-none-any.whl.

File metadata

  • Download URL: minipcn-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 8.3 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.0-py3-none-any.whl
Algorithm Hash digest
SHA256 ea86f9bbb90537771d933e92e1c57e0507fe6c840c6dc8c04586fe3686815aff
MD5 4015d06f5942b9395323b55d1ee87d57
BLAKE2b-256 51e432c9356ba981698dc2ef09b3d16862c2404b71f78dddb46b485528e9bd32

See more details on using hashes here.

Provenance

The following attestation bundles were made for minipcn-0.1.0-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