https://github.com/jo-phil/hopkins-statistic
A Python package for computing the Hopkins statistic to assess clustering tendency.
https://github.com/jo-phil/hopkins-statistic
cluster-analysis cluster-tendency clustering data-analysis data-science hopkins-statistic machine-learning python statistical-analysis statistics
Last synced: 21 days ago
JSON representation
A Python package for computing the Hopkins statistic to assess clustering tendency.
- Host: GitHub
- URL: https://github.com/jo-phil/hopkins-statistic
- Owner: jo-phil
- License: mit
- Created: 2025-12-02T20:21:09.000Z (6 months ago)
- Default Branch: main
- Last Pushed: 2026-05-07T21:31:49.000Z (27 days ago)
- Last Synced: 2026-05-07T23:41:11.031Z (27 days ago)
- Topics: cluster-analysis, cluster-tendency, clustering, data-analysis, data-science, hopkins-statistic, machine-learning, python, statistical-analysis, statistics
- Language: Python
- Homepage: https://jo-phil.github.io/hopkins-statistic/
- Size: 109 KB
- Stars: 1
- Watchers: 0
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
Awesome Lists containing this project
README
# hopkins-statistic
[](https://github.com/jo-phil/hopkins-statistic/actions/workflows/ci.yml "View workflow runs")
[](https://github.com/jo-phil/hopkins-statistic/actions/workflows/ci.yml?query=branch%3Amain+event%3Apush "View coverage report")
[](https://pypi.org/project/hopkins-statistic/ "View latest release on PyPI")
[](https://pypi.org/project/hopkins-statistic/ "View supported Python versions on PyPI")
[](https://jo-phil.github.io/hopkins-statistic/ "Read the documentation")
[](https://doi.org/10.5281/zenodo.18172791 "View on Zenodo")
[//]: # (--8<-- [start:opener])
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.
[Cross and Jain (1982)]: https://doi.org/10.1016/S1474-6670(17)63365-2 "Measurement of Clustering Tendency"
[Hopkins and Skellam (1954)]: https://doi.org/10.1093/oxfordjournals.aob.a083391 "A New Method for determining the Type of Distribution of Plant Individuals"
[//]: # (--8<-- [end:opener])
## Installation
```bash
pip install hopkins-statistic
```
## Usage
```python
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.