Skip to main content

modist

Interactive distribution widgets for marimo, in the style of koaning/wigglystuff. Drag the density curve to shape a distribution, then feed the params straight into a distribution constructor with a single splat.

modist widget example

Install

uv add modist            # or: uv pip install modist  (pip install modist)

Quickstart

import marimo as mo
import modist as md

w = mo.ui.anywidget(md.Normal())
w
params = w.value            # {'mu': ..., 'sigma': ...}
import pymc as pm
dist = pm.Normal.dist(**params)   # or pm.Beta / pm.Gamma / pm.StudentT

Families

Widget Params Domain Drag affordances
Normal mu, sigma free mean line → mu, ±1σ squares → sigma
Beta alpha, beta fixed [0, 1] mean line → translate, q25/q75 squares → concentrate
Gamma alpha, beta edge pinned at 0 mean line → translate, q25/q75 squares → reshape
StudentT mu, sigma, nu free mean line → mu, q75 square → sigma, tails dial → nu

StudentT's third parameter is a tails dial: drag it up for fatter tails (lower nu) or down for thinner tails (higher nu). Because nu has no natural on-curve landmark, its drag is a separate 1-D slider rather than a point you move on the density curve.

alpha/beta follow the PyMC / statistics convention (Gamma's beta is the rate, not scipy's scale). The lazy .scipy and .pymc adapters map to the right parametrization automatically:

n = md.Normal(mu=2.0, sigma=3.0)
n.scipy   # <scipy.stats.norm> via loc=/scale=
n.pymc    # pm.Normal.dist(mu=2.0, sigma=3.0)

g = md.Gamma(alpha=2.0, beta=3.0)
g.scipy   # scipy.stats.gamma(a=2.0, scale=1/3)  -- rate handled for you

w.value is a plain dict of the synced traits, so pm.X.dist(**w.value) works with no conversion.

Jupyter

The widgets are anywidget/ipywidgets under the hood, so they run in plain Jupyter too — no marimo required. Just display() the widget and read its .params (or .scipy) instead of wrapping it in mo.ui.anywidget(...):

import modist as md
from IPython.display import display

w = md.Normal(mu=0, sigma=1)
display(w)          # drag the curve to reshape it

w.params            # {'mu': ..., 'sigma': ...}

A full walkthrough notebook — all five families, live scipy stats, and a beta-prior combination example — lives at demos/jupyter_example.ipynb.

From a checkout:

uv sync --extra dev --extra scipy   # installs jupyter, ipykernel, jupytext
make jupyter                        # opens demos/jupyter_example.ipynb in JupyterLab

make jupyter registers the repo's .venv as a modist kernel, so the notebook uses exactly the installed packages. Requires a local JupyterLab (installed alongside jupyter via the dev extras).

How it works

Each family is its own anywidget class with a small set of synced parameter traits (no x_min/x_max/n_points). The view — SVG scaffold, pan/zoom, draggable hit lines, and per-family math — lives in a self-contained ESM module.

Source JS lives in js/ (js/base.js shared scaffold + one family file, all importing a vendored copy of jStat for pdf/cdf/quantile math). Anywidget delivers _esm as a Blob URL, which cannot resolve relative imports, so esbuild bundles each family (jStat inlined) into the committed src/modist/static/*.js files — the same pattern wigglystuff uses for its JS-heavy widgets.

Rebuilding the JS

make js          # esbuild js/*.js -> src/modist/static/*.js
make js-watch    # rebuild on every edit (for anywidget hot-reload dev)

Requires a local esbuild (npm install --no-save esbuild).

Development

make venv        # creates .venv with dev deps + esbuild
make test        # pytest
npm run test:js  # Playwright JS integration probes (headless Chromium)

Acknowledgements

  • jStat — JavaScript statistics library (MIT), vendored and bundled for the pdf/cdf/quantile math.
  • wigglystuff — the interaction and architecture model (one class per family, prebuilt ESM per class).

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

modist-0.2.0.tar.gz (115.4 kB view details)

Uploaded Source

Built Distribution

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

modist-0.2.0-py3-none-any.whl (119.2 kB view details)

Uploaded Python 3

File details

Details for the file modist-0.2.0.tar.gz.

File metadata

  • Download URL: modist-0.2.0.tar.gz
  • Upload date:
  • Size: 115.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: uv/0.12.8 {"installer":{"name":"uv","version":"0.12.8","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

File hashes

Hashes for modist-0.2.0.tar.gz
Algorithm Hash digest
SHA256 102c6ea9148b33067fd2b7834bffa8805a1a0092dcc861b29e807fdc585113bd
MD5 f97d4d95a5b6d8cdd9467202ef8fa1d5
BLAKE2b-256 73ccd7c4c302c25ac97285314c7001fdb6c791f21773bd6327cdde58e9967ff8

See more details on using hashes here.

File details

Details for the file modist-0.2.0-py3-none-any.whl.

File metadata

  • Download URL: modist-0.2.0-py3-none-any.whl
  • Upload date:
  • Size: 119.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: uv/0.12.8 {"installer":{"name":"uv","version":"0.12.8","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

File hashes

Hashes for modist-0.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 9741b9a185e3ab934567e0e9527ca443b4947f725521d9cd220e11a40dd57a47
MD5 57b25a75921b9db8240f4767b75a9b60
BLAKE2b-256 50e1b8712e4421132baf73f85cada91141b8e5a4d03184df42b67d5b99d9494b

See more details on using hashes here.

Release history Release notifications | RSS feed

0.3.0

2 files

This release

0.2.0 This release

2 files

0.1.1

2 files

0.1.0

2 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