Skip to main content

Hamiltonian sampling and analysis of sampled distributions

Project description

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.

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].

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

samppy-1.3.1.tar.gz (24.6 kB view details)

Uploaded Source

Built Distribution

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

samppy-1.3.1-py3-none-any.whl (27.0 kB view details)

Uploaded Python 3

File details

Details for the file samppy-1.3.1.tar.gz.

File metadata

  • Download URL: samppy-1.3.1.tar.gz
  • Upload date:
  • Size: 24.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.10.7

File hashes

Hashes for samppy-1.3.1.tar.gz
Algorithm Hash digest
SHA256 18c7d11f477770c9d1c8d833b5889a2388ffb19970cc07e6116b1fc475f2230a
MD5 813e4b8332df5e8dcca11050cd7bae48
BLAKE2b-256 ac601b108e2fe02fb205669a06dfce3b70205353a1f335d0ed58287e9e6d0a4d

See more details on using hashes here.

File details

Details for the file samppy-1.3.1-py3-none-any.whl.

File metadata

  • Download URL: samppy-1.3.1-py3-none-any.whl
  • Upload date:
  • Size: 27.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.10.7

File hashes

Hashes for samppy-1.3.1-py3-none-any.whl
Algorithm Hash digest
SHA256 d96412bd3ea7830c8e73c98fff7c80478fcb3ac6a71a89064005a26a7f07053f
MD5 01da1f588df185256916e2b37db81299
BLAKE2b-256 299328f2bf3b367e018aa26e7cfcfda52f256fd3df8d9f23ae8296b73ff6189d

See more details on using hashes here.

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