How this calculation works
Hopkins compares nearest-neighbor spacing in the observed data with spacing from independent reference locations. It measures departure from a chosen spatial reference, rather than discovering the number or shape of clusters.
For n d-dimensional data points, choose m distinct data indices without replacement and m independent points uniform in the supplied hyperrectangle (or accept those reference points explicitly). For each sampled data point take distance w_i to nearest other data point, excluding self; for each reference point take distance u_i to nearest data point. H=sum(u_i^d)/(sum(u_i^d)+sum(w_i^d)). Fix seed and disclose distance scaling. Reject zero denominator, duplicates as a diagnostic, degenerate region and points outside it. Do not use raw distances in dimension>1.A worked example
With the prefilled inputs, meanHopkins = 0.5558816623252081.
Good to know
Distances raised to dimension; near one indicates clustering relative to supplied uniform box. Repeated samples are not independent confidence replicates.
Reference: Primary method reference or author-maintained documentation (opens in a new tab) ↗
Ask whether a uniform reference fits
Hopkins compares nearest-neighbor spacing in the observed data with spacing from independent reference locations. It measures departure from a chosen spatial reference, rather than discovering the number or shape of clusters.
The reference region is part of the question. A large empty rectangle around a curved data cloud can produce a high value even when the cloud has no meaningful internal grouping.
Compare with the Hierarchical clustering dendrogram calculator from pairwise distances. Assess departure from spatial randomness using nearest-neighbor distances to observed and reference points; hierarchical clustering always supplies a tree and does not test cluster tendency.
Define the region and units
Use the prefilled input structure and preserve the declared column or index order. Enter the bounds of a region where an unclustered point could actually occur. Every observed point should lie within it, and each coordinate needs a strictly positive range.
Distance treats coordinate units numerically. Rescaling one axis can change neighbors and the result, so choose a justified standardization policy and keep it fixed across comparisons. The runnable input uses thirty to one thousand points in two to five coordinates. Each coordinate needs its own lower and upper bound, and every point must lie inside the corresponding rectangle. A narrow band of observations inside a much wider rectangle leaves empty reference volume that contributes strongly to the statistic. Selecting bounds after seeing a convenient result therefore changes the question being answered. The illustration with a few points explains the distance arithmetic only; the interface generates its own uniform reference locations and does not accept a handpicked list of favorable reference points.
Keep self-neighbors out
For a sampled data point, the nearest neighbor must be a different observation. Accidentally counting the point itself produces zero observed spacing and pushes the statistic toward the clustering end.
Reference locations are independently generated within the region and compare with all observed points. They are not taken from the data and are not forced to avoid the observed locations.
Why distances are raised to dimension
A distance in d dimensions corresponds to a neighborhood volume proportional to its dth power. The Hopkins ratio therefore accumulates powered distances, with the same dimension applied to both spacing sets.
Using unpowered distances in several dimensions gives a different statistic. The calculator should display the dimension and distance convention alongside the reported ratio to make external comparisons meaningful.
Work through four points
For one-dimensional points 0,1,9,10, sample the observations at 1 and 9. Each has nearest-other distance one; choose independent reference locations 4 and 6, each distance three from the data.
The ratio is (3+3)/(3+3+1+1)=0.75. These hand-calculated reference points explain the arithmetic only; the supported public interface uses seeded random reference draws in two or more dimensions.
Understand randomness and convention
Under a suitable uniform reference, values around one-half are a useful baseline. Large values in this convention indicate reference locations tend to be farther from the observed cloud than observations are from one another.
A single draw is noisy. Repeat prespecified draws or retain a reproducible seed, and check whether another implementation reports H or its complement before comparing apparently opposite conclusions.
Avoid interpreting a score as a clustering solution
A high value does not identify the correct clustering algorithm, the number of groups or whether the groups are useful. Outliers, duplicate observations and boundaries can drive the same numerical pattern.
Inspect the data geometry and the reference region before choosing a downstream method. A nearest-neighbor diagnostic is evidence about spacing, not a certificate of a scientifically meaningful segmentation. For every repetition, the seed drives a random sample of distinct observed indices and independently generated box locations. A sampled observation compares with all other observations, excluding only itself. Generated reference locations compare with the complete original point cloud. The repeated values, minimum, maximum and mean describe Monte Carlo variation for this particular design; they are not a confidence interval for an unknown number of clusters. Duplicate points are rejected rather than perturbed by invisible jitter. If measurement rounding produced genuine duplicates, deciding how to handle that rounding belongs before this diagnostic and should be recorded with any later clustering analysis. Distances raised to dimension; near one indicates clustering relative to supplied uniform box. Repeated samples are not independent confidence replicates.
A few questions, answered
Should the sampled observation count be n?
No. A smaller distinct sample is normally used; the supported count and seed should be reported.
Why exclude the point itself?
Otherwise every sampled observation has nearest distance zero and the statistic becomes biased toward one.
Can I compare Celsius and income directly?
Only with a justified scaling convention; mixed coordinate magnitudes otherwise dominate Euclidean distances.
Does0.75 mean75% of points form clusters?
No. It is a spacing ratio against the specified uniform reference, not a fraction of clustered observations.