This release is a pre-release and may not be stable for production use.
sequince-density
sequince-density provides density estimators for use with the sequince SMC
framework, including fitted proposal distributions and normalizing flows for
preconditioned sampling.
Installation
sequince-density can be installed directly from PyPI:
pip install sequince-density
However, we recommend also installing the relevant dependencies for the features you plan to use. See below for more details.
Features
- Normalizing-flow adapters for Zuko (PyTorch) and FlowJAX (JAX).
- Gaussian-mixture proposals fitted with scikit-learn.
- Integration with Sequince's
FlowTransformfor mutation in a learned latent space andFlowProposalfor fitted proposal distributions.
Quick start
Normalizing flows
Install the optional dependencies for your chosen backend:
pip install "sequince-density[zuko]"
# Alternatively, for the JAX backend:
pip install "sequince-density[flowjax]"
Fit a Zuko flow to a two-dimensional sample population, then draw samples and evaluate their log densities:
import numpy as np
from sequince_density import ZukoFlow
rng = np.random.default_rng(42)
particles = rng.normal(size=(2000, 2))
flow = ZukoFlow(dims=2, flow_class="MAF", hidden_features=[32, 32])
flow.fit(particles, n_epochs=100, batch_size=500, rng=42)
samples, log_q = flow.sample_and_log_prob(256, rng=43)
ZukoFlow returns PyTorch tensors; FlowJax returns JAX arrays.
For preconditioned SMC, pass an unfitted flow to FlowTransform and use the
transform as the particle_transform argument to
make_standard_bayesian_smc. The mutation step fits it to the current particle
population:
from sequince.transforms import FlowTransform
transform = FlowTransform(
ZukoFlow(dims=2, flow_class="MAF", hidden_features=[32, 32]),
fit_kwargs={"n_epochs": 100, "batch_size": 500},
)
Gaussian mixture models
GMM support is provided via scikit-learn and can be installed with:
pip install "sequince-density[gmm]"
import numpy as np
from sequince_density import GaussianMixtureProposal
particles = np.random.default_rng(42).normal(size=(2000, 2))
proposal = GaussianMixtureProposal(n_components=4).fit(particles, rng=42)
samples, log_q = proposal.sample_and_log_prob(256, rng=43)
Fitting expects particles shaped (n_particles, n_dimensions). Nonuniform
weights are not supported; use an equal-weight population, such as particles
after resampling.
Proposal distributions
Both Gaussian mixtures and normalizing flows can provide a fitted starting
distribution for SMC. GaussianMixtureProposal implements Sequince's proposal
interface directly. Wrap a flow in FlowProposal to use the same interface,
including conversion to the SMC particle backend:
from sequince.proposals import FlowProposal
proposal = FlowProposal(
ZukoFlow(dims=2, flow_class="MAF", hidden_features=[32, 32]),
fit_kwargs={"n_epochs": 100, "batch_size": 500},
).fit(particles, rng=42)
For either fitted proposal type, pass proposal as log_proposal to
make_standard_bayesian_smc and draw the initial particles from that same
proposal. SMC then bridges from the proposal to the target posterior.
In an ASPIRE-style analysis, a flow is fitted to samples from an initial analysis and used as the starting proposal for a new SMC run with an updated likelihood.
Full proposal examples will be linked here once published in
sequince-examples.
Documentation
See the sequince density documentation for installation, density fitting, and integration with Sequince proposals and transforms.
See the changelog for release notes and unreleased changes.
Examples
The sequince-examples
repository and corresponding documentation contain examples highlighting
different features in sequince.
Contributing
Bug reports, feature requests, and pull requests are welcome via the GitHub repository. Please see the contributing guidelines and AI policy.
Related repositories
The following repositories are part of the sequince ecosystem:
sequince: the mainsequincerepositorysequince-bilby: provides an interface for using prebuiltsequincesamplers withbilbyorng: provides cross-backend random number generationacai: provides array-API compatible control flow and iteration
License
Licensed under the MIT License.
Metadata
Release files for sequince-density 0.1.0b1
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 |
|---|---|---|---|---|
| sequince_density-0.1.0b1.tar.gz | 34.4 kB | With provenance | Details for sequince_density-0.1.0b1.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| sequince_density-0.1.0b1-py3-none-any.whl | Python 3 | none | any | Details for sequince_density-0.1.0b1-py3-none-any.whl |
Total release size: 48.8 kB
Release files / sequince_density-0.1.0b1.tar.gz
| Download URL | sequince_density-0.1.0b1.tar.gz |
|---|---|
| Size | 34.4 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
728e90d8591387ebaccf6da62f137d5298d7f191be54bc78b88417faf5764332
|
|
BLAKE2b-256 checksum How to use checksums |
63e16a2787df7e47d29a9f25caad34a30ba9aac6b1c7b789cf40936d72fd5e86
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
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.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Oct 27, 2026.
Transparency logRelease files / sequince_density-0.1.0b1-py3-none-any.whl
| Download URL | sequince_density-0.1.0b1-py3-none-any.whl |
|---|---|
| Size | 14.5 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
00b4ecb3785d48b40f9f21fd22a894eff1dd052c3224900d0644fe3223a21f6a
|
|
BLAKE2b-256 checksum How to use checksums |
8eaad8c53119fc52b42241c5449836e1a16c3fabc1cf4cd4b0553c71e8834ce4
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
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.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Oct 27, 2026.
Transparency logSecurity for sequince-density 0.1.0b1
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.
Full provenance
Both files in this release have been uploaded with provenance metadata.
Attestation for sequince_density-0.1.0b1.tar.gz
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Oct 27, 2026.
Transparency logA 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.