Skip to main content

Dirichlet

A Python package to estimate the Dirichlet distribution, calculate maximum likelihood, and test for independence from a variable based on fitting nested Dirichlet distribution hypotheses.

Most of this package is a port of Thomas P. Minka's wonderful Fastfit MATLAB code. Much thanks to him for that and his clear paper "Estimating a Dirichlet distribution".

Dirichlet Test

This likelihood ratio test for independence will determine whether two Dirichlet-distributed data sets are likely to be from the same distribution or from two different ones, much like a chi-square or G-test for independence, but with Dirichlet models.

Simplex Plots

The dirichlet.simplex module creates scatter, contour, and filled contour 2-simplex plots. To use this, be sure to install the simplex package "extra" (e.g. pip install dirichlet[simplex]).

Caveats

Note that this package at the moment doesn't support sparse data vectors due to the numerical fitting algorithm that uses the gamma function. Possibly some sort of additive smoothing would make this package work in your context, but that will depend on your application.

Installation

pip install dirichlet
# or
uv add dirichlet

This has only been tested with Python 3.10+. Other versions may work, but they haven't been tested.

Development

To install dev tooling, run:

uv sync --frozen --locked --all-groups --all-extras

# To format
uv run ruff format

# To test
uv run pytest

# To lint
uv run ruff

A Github workflow will run tests against several Python versions.

Release files for dirichlet 1.0.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 dirichlet 1.0.0
File Size Uploaded
dirichlet-1.0.0.tar.gz 6.5 kB Details

Built distribution (wheel)

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

Total release size: 13.8 kB

Release files / dirichlet-1.0.0.tar.gz

Download URL dirichlet-1.0.0.tar.gz
Size 6.5 kB
Tags Source
SHA-256 checksum
How to use checksums
b4d872137f2a301b8511d53b4f8ebd532cc64206a6a2a1e089007d8812200664
BLAKE2b-256 checksum
How to use checksums
51fa5755c4fa06dd36f233e537ea63b7fca65466cd9716b52aa2fc3eb9b02170
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.12.9

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 9, 2025.

Transparency log

Release files / dirichlet-1.0.0-py3-none-any.whl

Download URL dirichlet-1.0.0-py3-none-any.whl
Size 7.3 kB
Tags Python 3
SHA-256 checksum
How to use checksums
d47fb0c8f1392b5e4749a895709f0fc8befa121e368c3c9c90cd0c17e791fb74
BLAKE2b-256 checksum
How to use checksums
c853c95f9cf52aa562102731330aed9e7bdd145916f52c971ae1074c36b5c8a0
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.12.9

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 9, 2025.

Transparency log

Release history Release notifications | RSS feed

This release

1.0.0 This release

2 release files

0.9

2 release files

0.8

2 release files

0.7

1 release file

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