Skip to main content

Calculates Dirichlet test and plots 2-simplex Dirichlets

Project description

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.

Project details


Download files

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

Source Distribution

dirichlet-1.0.0.tar.gz (6.5 kB view details)

Uploaded Source

Built Distribution

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

dirichlet-1.0.0-py3-none-any.whl (7.3 kB view details)

Uploaded Python 3

File details

Details for the file dirichlet-1.0.0.tar.gz.

File metadata

  • Download URL: dirichlet-1.0.0.tar.gz
  • Upload date:
  • Size: 6.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.12.9

File hashes

Hashes for dirichlet-1.0.0.tar.gz
Algorithm Hash digest
SHA256 b4d872137f2a301b8511d53b4f8ebd532cc64206a6a2a1e089007d8812200664
MD5 07c573043c98ffda29abda3b277846d0
BLAKE2b-256 51fa5755c4fa06dd36f233e537ea63b7fca65466cd9716b52aa2fc3eb9b02170

See more details on using hashes here.

Provenance

The following attestation bundles were made for dirichlet-1.0.0.tar.gz:

Publisher: publish.yml on ericsuh/dirichlet

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file dirichlet-1.0.0-py3-none-any.whl.

File metadata

  • Download URL: dirichlet-1.0.0-py3-none-any.whl
  • Upload date:
  • Size: 7.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.12.9

File hashes

Hashes for dirichlet-1.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 d47fb0c8f1392b5e4749a895709f0fc8befa121e368c3c9c90cd0c17e791fb74
MD5 894b3ae8551c0a900046053b3095bc0d
BLAKE2b-256 c853c95f9cf52aa562102731330aed9e7bdd145916f52c971ae1074c36b5c8a0

See more details on using hashes here.

Provenance

The following attestation bundles were made for dirichlet-1.0.0-py3-none-any.whl:

Publisher: publish.yml on ericsuh/dirichlet

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page