Skip to main content

PyMC Extras

This library includes various experimental or otherwise special-purpose extras for use with PyMC that have been extracted from the exoplanet project. It's primary components are some helper functions for non-linear optimization and some custom distributions.

Installation

You'll need a Python installation, and it can often be best to install PyMC using conda so that it can handle all the details of compiler setup. This step is optional, but I would normally create a clean conda environment for projects that use PyMC:

# Optional
conda create -n name-of-my-project pymc
conda activate name-of-my-project

The easiest way to install this package is using pip:

python -m pip install -U pymc-ext

This will also update the dependencies like PyMC, which is probably what you want because this is only tested on recent versions of that package.

Optimization

When PyMC added a warning to the pm.find_MAP function, we implemented a custom non-linear optimization framework in exoplanet because it is often useful to be able to optimize (at least) some parameters when initializing the sampler for many problems in astrophysics (and probably elsewhere). While pm.find_MAP no longer complains, the pymc_ext.optimize function is included here for backward compatibility even though it should have similar behavior to pm.find_MAP. To use this function, you'll do something like the following:

import pymc_ext as pmx

with model:
    soln = pmx.optimize(vars=[var1, var2])
    soln = pmx.optimize(start=soln, vars=[var3])

Distributions

Most of the custom distributions in this library are there to make working with periodic parameters (like angles) easier. All of these reparameterizations could be implemented manually without too much trouble, but it can be useful to have them in a more compact form. Here is a list of the included distributions and short descriptions:

  • pmx.unit_disk: Two dimensional parameters constrained to live within the unit disk. This will be useful when you have an angle and a magnitude that must be in the range from zero to one (for example, an eccentricity vector for a bound orbit). This distribution is constrained such that the sum of squares along the zeroth axis will always be less than one. Note that the shape of this distribution must be two in the zeroth axis.
  • pmx.angle: An angle constrained to be in the range -pi to pi. The actual sampling is performed in the two-dimensional vector space (sin(theta), cos(theta)) so that the sampler doesn't see a discontinuity at pi. As a technical detail, the performance of this distribution can be affected using the regularization parameter which helps deal with pathological geometries introduced when this parameter is well/poorly constrained. The default value (10.0) was selected as a reasonable default choice, but you might get better performance by adjusting this.

It's important to note that these are not Distribution objects, but rather functions that will add Distribution objects to the model, and return the reparameterized variable of interest. The ergonomics of this interface are questionable, but it's easier to maintain this interface than one that implements custom Distribution objects.

License

Copyright 2020-2022 Dan Foreman-Mackey and contributors.

pymc-ext is free software made available under the MIT License. For details see the LICENSE file.

Metadata

Release files for pymc-ext 1.0.1

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

Source distribution (sdist)

Source distribution for pymc-ext 1.0.1
File Size Uploaded Provenance Actions
pymc_ext-1.0.1.tar.gz 15.3 kB Without provenance Details for pymc_ext-1.0.1.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for pymc-ext 1.0.1
File Interpreter ABI Platform Actions
pymc_ext-1.0.1-py2.py3-none-any.whl Python 3, Python 2 none any Details for pymc_ext-1.0.1-py2.py3-none-any.whl

Total release size: 23.7 kB

Release files / pymc_ext-1.0.1.tar.gz

Download URL pymc_ext-1.0.1.tar.gz
Size 15.3 kB
Tags Source
SHA-256 checksum
How to use checksums
50c596a7c681308bf300f1b1408fd6d3c89c72692019332ddf293dbc779bcb8c
BLAKE2b-256 checksum
How to use checksums
c0d4e133995b71e2f245bb68f8fe3c3275114ee60075a4cf13128f9c45891a67
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/5.0.0 CPython/3.9.18

Release files / pymc_ext-1.0.1-py2.py3-none-any.whl

Download URL pymc_ext-1.0.1-py2.py3-none-any.whl
Size 8.4 kB
Tags Python 2 Python 3
SHA-256 checksum
How to use checksums
9b4336a022dd9823073c9ffdb41f1a67171b8b0f80435392dd822d3b4d9ce182
BLAKE2b-256 checksum
How to use checksums
84fd2a95356ca6916a2378b85c7ec34dffec62581138c2d07d2a538c9723ae73
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/5.0.0 CPython/3.9.18

Security for pymc-ext 1.0.1

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