Skip to main content

Compute the Hopkins statistic to assess clustering tendency.

Project description

hopkins-statistic

CI Coverage PyPI - Version PyPI - Python Version Docs DOI

hopkins-statistic is a library for computing the Hopkins statistic to assess clustering tendency (also known as clusterability) by testing for departure from complete spatial randomness (CSR) in point patterns.

This implementation defaults to the Cross and Jain (1982) formulation, raising distances to the power of the data dimension. In two dimensions, this matches the original definition by Hopkins and Skellam (1954). Because the resulting statistic follows a beta distribution under the null hypothesis, p-values can be computed analytically, avoiding the need for Monte Carlo simulations.

Installation

pip install hopkins-statistic

Usage

import numpy as np
from hopkins_statistic import hopkins

rng = np.random.default_rng(42)
X = rng.uniform(size=(100, 2))

statistic = hopkins(X, rng=rng)
print(f"{statistic:.3f}")
#> 0.514

License

This project is licensed under the terms of the MIT license.

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

hopkins_statistic-0.6.1.tar.gz (7.4 kB view details)

Uploaded Source

Built Distribution

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

hopkins_statistic-0.6.1-py3-none-any.whl (9.8 kB view details)

Uploaded Python 3

File details

Details for the file hopkins_statistic-0.6.1.tar.gz.

File metadata

  • Download URL: hopkins_statistic-0.6.1.tar.gz
  • Upload date:
  • Size: 7.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: uv/0.11.14 {"installer":{"name":"uv","version":"0.11.14","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 hopkins_statistic-0.6.1.tar.gz
Algorithm Hash digest
SHA256 d19fd92efdd1e6c8b20026f8d3e949a65fe01b0ee05b154414609e10993d1d1b
MD5 0db565145b98ce648726a5abeade5a75
BLAKE2b-256 5bdfe07d211ebe7c7a3b83a34830c9130a3e8a24bb287c1c8017491837cb4485

See more details on using hashes here.

File details

Details for the file hopkins_statistic-0.6.1-py3-none-any.whl.

File metadata

  • Download URL: hopkins_statistic-0.6.1-py3-none-any.whl
  • Upload date:
  • Size: 9.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: uv/0.11.14 {"installer":{"name":"uv","version":"0.11.14","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 hopkins_statistic-0.6.1-py3-none-any.whl
Algorithm Hash digest
SHA256 28066a5cf26871b8136697279a6094ca127948408117d3b4b0a97e790e3a5c8b
MD5 24d4a1bb5d4e6541e740ecb63efffe36
BLAKE2b-256 ccd8acb3a6456cb71975d962ce0d2f75aa673d0edd39816751b649ac5aa0e73e

See more details on using hashes here.

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