Skip to main content

A minimalistic preconditioned Crank-Nicolson MCMC sampler

Project description

minipcn

A minimalistic implementation of preconditioned Crank-Nicolson MCMC sampling.

Installation

Currently, the minipcn is only available to install from source. Clone the repo and then run:

pip install .

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.

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

Uploaded Python 3

File details

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

File metadata

  • Download URL: minipcn-0.1.0b1.tar.gz
  • Upload date:
  • Size: 12.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.12.9

File hashes

Hashes for minipcn-0.1.0b1.tar.gz
Algorithm Hash digest
SHA256 0e5e84f8fb4d4514d3234a43ba019d1dcff069ea8638615f2413c364ea105d29
MD5 bd322772db0cd2c8ae80bbc747953646
BLAKE2b-256 a395da581f3997480736ca3e79085e3486ab3767659646f9014343941e29c760

See more details on using hashes here.

Provenance

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

File metadata

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

File hashes

Hashes for minipcn-0.1.0b1-py3-none-any.whl
Algorithm Hash digest
SHA256 4bb2b44309f183c4252e29627577c764c04f7ed3277c09afdf11fe957257d14a
MD5 121332612ad9ed0a76774f3c517d1f10
BLAKE2b-256 8ce4580d94109a54c7238c63f1f9d50379e4b419651dc7f03075ffb6f821dc2b

See more details on using hashes here.

Provenance

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