Khisto — Histograms that fit your data

Drop-in replacements for numpy.histogram and plt.hist with adaptive, variable-width bins powered by the Khisto algorithm. Dense regions get fine bins, sparse regions get wide ones — no tuning needed.

Before / Equal-width and After / Khisto, using the same data, bin counts and scales. Khisto reveals the Lévy peak and heavy tail on logarithmic axes and avoids artificial spikes in integer Adult ages. Before / Equal-width and After / Khisto, using the same data, bin counts and scales. Khisto reveals the Lévy peak and heavy tail on logarithmic axes and avoids artificial spikes in integer Adult ages.

Same data, bin counts and scales. Ages: UCI Adult.

Get started

Density by default

Unlike NumPy and Matplotlib, Khisto uses density by default. Learn how to read variable-width histograms.

pip install khisto                # core (NumPy only)
pip install "khisto[matplotlib]"  # + plotting
import numpy as np
import khisto

data = np.random.normal(0, 1, 10_000)
hist, bin_edges = khisto.histogram(data)          # optimal bins, no guessing
NumPy-like API

histogram(data) returns (hist, bin_edges) — same shape as numpy.histogram, better bins.

khisto.histogram
Matplotlib integration

khisto.matplotlib.hist plots like plt.hist with density, cumulative, step, and log-scale support.

khisto.matplotlib
Core engine

compute_histograms exposes every granularity level so you can pick the resolution that suits your analysis.

khisto.core
Interactive demo

A runnable notebook tour covering all features.

Khisto — optimal binning histograms
Counts or density?

See why counts mislead when bins have different widths.

Counts vs Density
Histograms - Khiops

Go further, from the simplest histogram to the most complex.

Histograms - Khiops (opens in a new tab)