Skip to main content

Package samppy implements Hamiltonian Markov-chain sampling and some additional analysis methods for multivariate probability distributions.

The probability distribution is represented only by an array of independent and identically distributed (i.i.d.) samples drawn from the distribution.

The package includes four modules:

  • Module hamiltonian_sampler implements Hamiltonian Markov-Chain sampling. A HamiltonianSampler instance can generate random samples of a multivariate probability distribution, defined only by an non-normalized log-likelihood function, and the gradient of that function.

    The generated batch of sample vectors is stored in a 2D numpy array, either as rows or as columns.

    Class HamiltonianSampler defines a standard isotropic sampler. Class HamiltonianBoundedSampler is a subclass also allowing one- or two-sided interval limits for all vector elements.

  • Module credibility includes functions to estimate jointly credible differences and/or correlations between pairs of elements in a random vector with a multivariate probability distribution, represented only by samples.

  • A separate module credibility_pd has the same functionality, but operates on input data in Pandas DataFrame or Series format.

  • Module sample_entropy includes a function to estimate the differential entropy of a multivariate probability distribution, represented only by samples. The entropy is estimated by the Kozachenko-Leonenko nearest-neighbor approximation (Singh and Poczos, 2016).

Usage

This package was developed mainly for use by other projects. It is distributed separately because it may be useful for other purposes.

The Hamiltonian sampler code was inspired by the LAHMC project by Jasha Sohlstein. The present implementation includes some safety features to facilitate its use. The present sampler does not include sampling within a general subspace manifold, but it allows bounded ranges for vector elements.

Requirements

The package requires recent versions of Numpy and Scipy. These are automatically installed. Pandas is not installed automatically, because the module requiring Pandas input will only be called from other program(s) that already use Pandas.

New in version 1.3.2

Module credibility_pd modified for improved speed. Tested with Pandas v. 2.3, should work also with Pandas v. 3. No change to other modules.

References

R M Neal (2011): MCMC using Hamiltonian dynamics. Ch. 5 in Brooks et al. (eds) Handbook of Markov Chain Monte Carlo. Chapman and Hall / CRC Press.

A. Leijon, G. E. Henter, and M. Dahlquist (2016): Bayesian analysis of phoneme confusion matrices. IEEE Transactions on Audio, Speech, and Language Processing 24(3):469–482. (Describes an application of credible-difference calculation.)

A. Leijon, P. von Gablenz, I. Holube, J. Taghia, and K. Smeds (2023). Bayesian analysis of ecological momentary assessment (EMA) data collected in adults before and after hearing rehabilitation. Frontiers in Digital Health, 5(1100705). download

F Perez-Cruz (2008): Estimation of Information Theoretic Measures for Continuous Random Variables. Advances in Neural Information Processing Systems 21 (NIPS 2008).

S Singh and B Poczos (2016): Analysis of k-nearest neighbor distances with application to entropy estimation. arXiv:1603.08578 [math.ST].

Metadata

Release files for samppy 1.3.3

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for samppy 1.3.3
File Size Uploaded Provenance Actions
samppy-1.3.3.tar.gz 22.8 kB Without provenance Details for samppy-1.3.3.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for samppy 1.3.3
File Interpreter ABI Platform Actions
samppy-1.3.3-py3-none-any.whl Python 3 none any Details for samppy-1.3.3-py3-none-any.whl

Total release size: 49.8 kB

Release files / samppy-1.3.3.tar.gz

Download URL samppy-1.3.3.tar.gz
Size 22.8 kB
Tags Source
SHA-256 checksum
How to use checksums
7fc34882ca3bf9bf03e3ce8a5723051410296eff426597c056de950f3d57c5a4
BLAKE2b-256 checksum
How to use checksums
73f4e6301ead4ff7acfda9ad050b14836390107ee2018991af50fd3fbb5cc92c
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.13.2

Release files / samppy-1.3.3-py3-none-any.whl

Download URL samppy-1.3.3-py3-none-any.whl
Size 27.0 kB
Tags Python 3
SHA-256 checksum
How to use checksums
1e4ee78333e25f5418d0b87a2f0aa33894933c3ab62f33b36d2585fc86769545
BLAKE2b-256 checksum
How to use checksums
7c0f5a04d29b2af658fc4357538144c5d0a9946dcd671065a015d51988720988
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.13.2

Security for samppy 1.3.3

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.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page