Metadata-Version: 2.4
Name: hopkins-statistic
Version: 0.1.0
Summary: Compute the Hopkins statistic to assess clustering tendency.
Keywords: clustering,clustering-tendency,data-mining,hopkins-statistic,machine-learning,statistics
Author: Johann Philipp Gorzny
License-Expression: MIT
License-File: LICENSE
Classifier: Development Status :: 4 - Beta
Classifier: Intended Audience :: Developers
Classifier: Intended Audience :: Science/Research
Classifier: Programming Language :: Python
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Programming Language :: Python :: 3.13
Classifier: Programming Language :: Python :: 3.14
Classifier: Topic :: Scientific/Engineering :: Information Analysis
Classifier: Typing :: Typed
Requires-Dist: numpy>=2.0.0
Requires-Dist: scipy>=1.13.0
Requires-Python: >=3.11
Project-URL: Documentation, https://jo-phil.github.io/hopkins-statistic/
Project-URL: Repository, https://github.com/jo-phil/hopkins-statistic
Description-Content-Type: text/markdown

# hopkins-statistic

[![CI](https://github.com/jo-phil/hopkins-statistic/actions/workflows/ci.yml/badge.svg)](https://github.com/jo-phil/hopkins-statistic/actions/workflows/ci.yml)
[![Docs](https://github.com/jo-phil/hopkins-statistic/actions/workflows/docs.yml/badge.svg)](https://jo-phil.github.io/hopkins-statistic/)

A Python package for computing the Hopkins statistic to test for departure from
complete spatial randomness (CSR), often used to assess clustering tendency.

## Installation

```bash
pip install hopkins-statistic
```

## Usage

```python
import numpy as np
from hopkins_statistic import hopkins

rng = np.random.default_rng(42)

# Clustered test data
centers = np.array([[0, 0], [0, 1]])
labels = rng.integers(len(centers), size=100)
X = centers[labels] + rng.normal(scale=0.1, size=(100, 2))

# For strongly clustered data, the statistic is often > 0.7
H = hopkins(X, rng=rng)
print(f"{H:.2f}")
#> 0.77
```

## License

MIT.
See [LICENSE](https://github.com/jo-phil/hopkins-statistic/blob/main/LICENSE).
