Skip to main content

NISMO

NISMO is a Python implementation of Morphing Importance Nested Sampling for Bayesian evidence estimation and weighted posterior inference. It uses a fixed, normalized importance distribution to define the nested-sampling target and supports rejection, random-walk, ensemble, and parallel replacement strategies.

NISMO is alpha research software. Validate evidence accuracy and sampling efficiency with repeated runs on your target problem. The fixed importance distribution must cover every region where the likelihood times prior is nonzero; missing support can bias the result. The adaptive-Morph proposal is explicitly heuristic and can also bias evidence estimates.

Installation

Install the standard user stack from PyPI:

python -m pip install "nismo[all]"

The base package requires only NumPy and SciPy. Optional extras are available individually:

  • nismo[morph] adds MorphZ proposal fitting;
  • nismo[plot] adds Matplotlib diagnostics;
  • nismo[progress] adds the tqdm terminal/notebook display.

Until the first PyPI release is published, install the repository version with:

python -m pip install "nismo[all] @ git+https://github.com/nz-gravity/nismo.git@main"

Python 3.10 through 3.12 are tested.

Quick start

import numpy as np

from nismo import CallableModel, MorphProposal, NISMOSampler

LOG_2PI = np.log(2.0 * np.pi)


def log_likelihood(theta: np.ndarray) -> np.ndarray:
    return -0.5 * (theta[:, 0] ** 2 + LOG_2PI)


def log_prior(theta: np.ndarray) -> np.ndarray:
    return -0.5 * ((theta[:, 0] / 2.0) ** 2 + LOG_2PI) - np.log(2.0)


model = CallableModel(
    ndim=1,
    parameter_names=("x",),
    log_likelihood_fn=log_likelihood,
    log_prior_fn=log_prior,
)

# Representative posterior draws used only to fit the importance density.
training_rng = np.random.default_rng(7)
posterior_samples = training_rng.normal(scale=np.sqrt(0.8), size=(2_000, 1))
importance_morph = MorphProposal.fit(
    posterior_samples,
    param_names=model.parameter_names,
    groups=[],
)

result = NISMOSampler(
    model=model,
    importance_morph=importance_morph,
    n_live=200,
    rng=42,
).run(dlogz=1e-2, progress=True)

print(result.logz, result.logzerr, result.termination_reason)
weighted_samples = result.all_points
weights = result.posterior_weights
equal_weight_samples = result.resample_equal(rng=43, n_samples=10_000)

Both model functions receive batches with shape (n, ndim) and return one natural-log value per row. log_prior must be normalized and include every normalization constant. Posterior training samples fit the importance density; they are not reused as live points.

Documentation

Runnable scripts and notebooks are under the examples/ directory.

Development

git clone https://github.com/nz-gravity/nismo.git
cd nismo
uv sync --extra dev
uv run ruff format --check .
uv run ruff check .
uv run mypy
uv run pytest -m "not slow"
uv build
uvx twine check dist/*

See the contribution guide and release guide.

License

NISMO is distributed under the BSD 3-Clause license.

Metadata

Release files for nismo 0.1.0

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

Source distribution (sdist)

Source distribution for nismo 0.1.0
File Size Uploaded
nismo-0.1.0.tar.gz 78.8 kB Details

Built distribution (wheel)

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

Total release size: 136.1 kB

Release files / nismo-0.1.0.tar.gz

Download URL nismo-0.1.0.tar.gz
Size 78.8 kB
Tags Source
SHA-256 checksum
How to use checksums
f1b33366b0eec3a0ea40bbbf3af250bb7d49d074bd2dee33f4de1203e78abafa
BLAKE2b-256 checksum
How to use checksums
9bdbb894a1225081df2cf7ae68f9684d8f3c2c5e34b17fafd806b5f16ca2438c
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

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 Aug 11, 2026.

Transparency log

Release files / nismo-0.1.0-py3-none-any.whl

Download URL nismo-0.1.0-py3-none-any.whl
Size 57.2 kB
Tags Python 3
SHA-256 checksum
How to use checksums
9e74c3814921fb3c8286970db1bbcca19bc5a52f469eaaf8bd0209221cf271b7
BLAKE2b-256 checksum
How to use checksums
4ebc9a9e857ed22e8e57fc2bd70bfbee4fd8ec3577b476ae2a12f0718b30eb8b
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

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 Aug 11, 2026.

Transparency log

Release history Release notifications | RSS feed

0.1.4

2 release files

0.1.2

2 release files

This release

0.1.0 This release

2 release files

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