GeoSSS: Geodesic Slice Sampling on the Sphere
This python package implements the novel and efficient tuning-free MCMC based inference methods to sample distributions defined on the sphere as published in JMLR. This includes the two variants GeoSSS (reject) and GeoSSS (shrink), where the latter is much faster and therefore recommended for practical utility.
In addition, the package also provides the implementation of the spherical variants of random-walk Metropolis-Hastings (Lie et al., 2023) and Hamiltonian Monte Carlo (Lan et al., 2014). As demonstrated in our paper, the proposed samplers outperform RWMH and HMC for several challenging target distributions.
To reproduce the results in the paper, see this section. However, to get started quickly, install the package and follow along with the demo provided below.
Installation
GeoSSS is available for installation from PyPI. Therefore, simply type:
pip install geosss
Minimal Example
We consider a target that is a mixture of von Mises-Fisher distributions on $\mathbb{S}^2$ with concentration parameter $\kappa=$ 80. By using 1000 samples, our samplers geoSSS (reject) and geoSSS (shrink) explore all modes, whereas RWMH and HMC get stuck in a single mode.
This demo can be created with the below script.
import geosss as gs
import numpy as np
# Create mixture of von Mises-Fisher distributions
mus = np.array([[0.87, -0.37, 0.33],
[-0.20, -0.89, -0.40],
[0.19, 0.22, -0.96]])
vmfs = [gs.VonMisesFisher(80.0 * mu) for mu in mus]
pdf = gs.MixtureModel(vmfs)
# Sampling parameters
n_samples, burnin = 1000, 100
init_state = np.array([-0.86, 0.19, -0.47])
seed = 3521
# Sample with different methods
samplers = {
'sss-reject': gs.RejectionSphericalSliceSampler, # very accurate, but slow
'sss-shrink': gs.ShrinkageSphericalSliceSampler, # reasonably accurate, but fast
'rwmh': gs.MetropolisHastings, # automatically tuned during burnin
'hmc': gs.SphericalHMC, # automatically tuned during burnin
}
samples = {name: cls(pdf, init_state, seed).sample(n_samples, burnin)
for name, cls in samplers.items()}
See the notebook demo.ipynb for visualization of the samples.
Development and Reproducibility
To reproduce results from the numerical illustrations section of the paper, check the scripts directory. Precomputed results can also be downloaded from the Science Data Bank and used with these scripts.
However, first installing the package and it's locked dependencies is necessary and can be done as follows:
- Clone the repository and navigate to the root of the folder,
git clone https://github.com/microscopic-image-analysis/geosss.git
cd geosss
- You can now create a virtual environment (with
condafor example),
conda create --name geosss-venv python=3.12 # or python >= 3.10, < 3.13
conda activate geosss-venv
- The dependencies can now be installed in this environment as,
pip install -r requirements.txt
pip install -e . --no-deps
Citation
If you use this package or ideas from the paper, please consider citing us.
@misc{habeck2023,
title={Geodesic slice sampling on the sphere},
author={Michael Habeck and Mareike Hasenpflug and Shantanu Kodgirwar and Daniel Rudolf},
year={2023},
eprint={2301.08056},
archivePrefix={arXiv},
primaryClass={stat.ME}
}
Metadata
Release files for geosss 0.3.5
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| geosss-0.3.5.tar.gz | 25.7 kB | Without provenance | Details for geosss-0.3.5.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| geosss-0.3.5-py3-none-any.whl | Python 3 | none | any | Details for geosss-0.3.5-py3-none-any.whl |
Total release size: 54.0 kB
Release files / geosss-0.3.5.tar.gz
| Download URL | geosss-0.3.5.tar.gz |
|---|---|
| Size | 25.7 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
2a310150525ec9d3a2cd06feca5d294cd2d88c0b3a67fae62f5ca484b412bb58
|
|
BLAKE2b-256 checksum How to use checksums |
9381641eb6adc187d84a493aac43f1444dc5f757ec499bf1c351a717b4154305
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
poetry/2.1.3 CPython/3.13.5 Darwin/25.0.0
|
Release files / geosss-0.3.5-py3-none-any.whl
| Download URL | geosss-0.3.5-py3-none-any.whl |
|---|---|
| Size | 28.3 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
94ee053c4de2100e9e8bb20344e7f0302e3aef20471031f37142499d86d1597d
|
|
BLAKE2b-256 checksum How to use checksums |
e9e3c163264bbf3b31422544b8cc04faf7041f94fdb6ee0790cb3ce5b2dd38d5
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
poetry/2.1.3 CPython/3.13.5 Darwin/25.0.0
|
Security for geosss 0.3.5
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.