Before we start, a few plain-word reminders so no symbol below is a surprise.
Recall What
k is (the number of neighbours)
k is just a nickname for the hyperparameter n_neighbors — the number of nearest neighbours each point is allowed to look at when we build the graph. So "sum to log2(k)" means "sum to log2(n_neighbors)". Small k = very local view; large k = broader, more global view.
Recall What
ρi and σi mean
ρi = distance (dhi) from point i to its closest neighbour (a floor we subtract off). σi = a per-point "stretch" tuned so the point's outgoing edge weights sum to log2(k) — this makes dense and sparse regions get treated fairly.
Recall What
a, b, and dlo are in the low-D kernel
In vij=1+a(dijlo)2b1, the distance dijlo=∥yi−yj∥2 is the straight-line distance between the two points in the 2-D picture. The two constants a and b are shape knobs fitted once (numerically, giving roughly a≈1.93,b≈0.79 for the default min_dist) so the kernel's flat-then-falling curve matches the min_dist you asked for. You never tune a,b by hand — UMAP solves for them from min_dist.
Recall What
min_dist is and its valid range
min_dist sets how tightly points are allowed to pack in the picture: it is the effective minimum gap the low-D kernel encourages. Valid range is [0,1) (typically 0.0–0.99; default ≈0.1). At 0 points may sit right on top of each other (tight, dense clusters); near 1 they are pushed apart into an airy, spread-out layout. It only reshapes a,b — it never touches the high-D graph.
The figure below shows both kernels together so you can see how a distance becomes a weight before you tackle the traps.
Figure s01. Horizontal axis = distance between two points; vertical axis = the resulting edge weight (0 to 1). The pale-yellow curve is the high-D map wij=exp(−max(0,dhi−ρ)/σ): flat at 1 until the nearest-neighbour floor ρ (pink dashed line), then exponential decay set by σ. The blue curve is the low-D kernel vij=1/(1+a(dlo)2b): notice its heavy tail — far-apart points in the picture still feel a faint pull, which is what prevents the "crowding problem".
TF — "UMAP preserves the actual distances between clusters, so a gap twice as wide means twice as different."
False. UMAP preserves ordering and connectivity of structure, not metric distances; inter-cluster gaps are qualitatively meaningful but not quantitatively to scale.
TF — "Because UMAP keeps some global structure, cluster sizes in the plot reflect how spread-out those groups are in high-D."
False. Cluster size in the embedding is mostly an artefact of min_dist and the repulsion dynamics, not high-D variance — a tiny plotted blob can be a huge manifold region.
TF — "By default (parallel threads, no fixed seed) UMAP gives an identical layout every run."
False. Default runs are non-deterministic — parallelism and random negative sampling make each layout differ (often just a rotation/reflection); you must fix the random seed and run single-threaded to reproduce a layout exactly.
TF — "The high-D weight wij is symmetric before we symmetrize it."
False. wij (how much i sees j) differs from wji because ρ and σ are per-point; that is exactly why the fuzzy-union step wij+wji−wijwji exists.
TF — "The fuzzy-union weight wijsym can exceed 1 if both directions are strong."
False. The −wijwji correction term caps it: even with wij=wji=1 you get 1+1−1=1, so it stays a valid membership in [0,1].
TF — "Increasing n_neighbors always improves the embedding."
False. Large k buys global structure but blurs fine local clusters and costs more; the 'best' k depends on whether you care about micro-clusters or the macro-layout.
TF — "min_dist changes what UMAP thinks the data is."
False. min_dist only shapes the low-D kernel (how tightly points may pack); it never touches the high-D graph wij, so it is purely a cosmetic/visualisation knob.
TF — "UMAP only works if you feed it Euclidean distances."
False. Euclidean is the default for dhi, but the fuzzy-graph construction accepts any metric (cosine, Manhattan, etc.); only the low-D distance dlo is fixed to Euclidean because it's a plot.
TF — "UMAP can embed a brand-new point without re-running the whole optimisation."
True. Once trained, UMAP can transform new points into the existing embedding — something t-SNE fundamentally cannot do without refitting.
TF — "Setting min_dist=0.0 guarantees clusters that touch will merge visually."
False. min_dist=0 only allows points to pack tightly; the attractive/repulsive forces from wij still keep genuinely different clusters apart.
Error — "We compute σi so that ∑jwij=k (the number of neighbours)."
The target is log2(k), not k. Summing to k would ignore the information-theoretic perplexity idea and over-connect every point.
Error — "ρi is subtracted so that even a point's farthest neighbour gets weight 1."
No — ρi is the nearest-neighbour distance, so only the closest neighbour (dijhi=ρi) gets weight exp(0)=1; farther ones still decay.
Error — "Cross-entropy here only rewards putting connected points close together."
It has two halves. The second term (1−w)log1−v1−w punishes putting unconnected points close — that repulsion is what stops everything collapsing to one dot.
Error — "Negative sampling picks the closest non-neighbours to push apart."
Negative sampling picks random pairs (mostly far ones, so w≈0) to cheaply and unbiasedly approximate the repulsive term; picking closest non-neighbours would be the wrong statistic and slow.
Error — "The low-D kernel vij=1+a(dlo)2b1 uses the same exponential form as the high-D weight."
No — high-D uses an exponential decay in dhi; low-D uses a rational, heavy-tailed (Student-t-like) kernel in dlo to avoid the crowding problem.
Error — "The constants a and b in the low-D kernel are hyperparameters you set by hand."
No — they are derived from min_dist by a one-time curve fit, so the knob you actually turn is min_dist; a,b follow from it automatically.
Error — "Since UMAP models a manifold, it must fail on data with no manifold (pure noise)."
It won't fail to run; it will happily produce a blob or spurious clusters. The trap is trusting structure that the algorithm invented from noise.
Error — "We use spectral embedding as the final answer, then polish with SGD."
Spectral embedding is only the initialisation (a good starting layout); SGD on the cross-entropy loss is what actually produces the result.
Why — Why does UMAP subtract ρi inside the exponent at all?
To enforce local connectivity: every point is guaranteed at least one full-strength edge (w=1), preventing isolated points and making the graph a single connected structure.
Why — Why log2(k) specifically, rather than any constant?
It ties the summed weight to perplexity (effective neighbour count), so dense and sparse regions of the manifold are modelled with matching "local scale" — this is what gives density-aware normalisation.
Why — Why cross-entropy instead of the KL-divergence that t-SNE uses?
Cross-entropy's two-sided form (attraction and repulsion, summed over all pairs) penalises both false-attraction and false-repulsion, which is what lets UMAP preserve global layout; KL in t-SNE mainly rewards local attraction and lets global distances drift.
Why — Why can UMAP afford to sum the repulsion over "all pairs" when that is O(n2)?
It doesn't compute them all — negative sampling replaces the exact all-pairs repulsion with a few random draws per edge, giving an unbiased gradient estimate at near-linear cost. See Cross-Entropy Loss.
Why — Why does UMAP need a repulsive term when we already reward keeping neighbours close?
Without repulsion the loss is trivially minimised by piling all points on top of each other; the (1−w)log1−v1−w term supplies the spreading force.
Why — Why is UMAP roughly O(n1.14) rather than O(n2) like naive t-SNE?
A brute-force pairwise graph is O(n2), but UMAP builds the neighbour graph with approximate nearest-neighbour descent (see Nearest Neighbors Algorithms): it starts from a rough graph and iteratively refines "my neighbour's neighbour is probably my neighbour," touching only a near-constant number of candidates per point. That empirically scales like n1.14 (the exponent is measured, not exact), and negative sampling makes the optimisation cost roughly linear too.
Why — Why does min_dist affect visual density but not which clusters appear?
Cluster membership is decided by the high-D graph wij, which min_dist never touches; min_dist only sets how much the attractive low-D force is capped at short range.
Edge — What happens for a point that is a total outlier, far from everything?
The ρi rule still forces one weight-1 edge to its nearest (though distant) neighbour, so it is tethered in — it won't be dropped, but it may sit at the periphery.
Edge — What if two points are identical (dijhi=0)?
They become ρi-nearest with weight 1 and are pulled essentially on top of each other; duplicate rows just stack, no division-by-zero because max(0,dhi−ρ) handles it.
Edge — What does n_neighbors=1 do, and how does it differ from n_neighbors=2?
With k=1 each point connects only to its single nearest neighbour, so the directed graph is essentially a matching — extremely fragmented, with log2(1)=0 making the σ calibration degenerate. With k=2 there is finally overlap between neighbourhoods, so small chains/clusters can begin to form; k=1 is effectively unusable while k=2 is merely very local.
Edge — What if n_neighbors is set larger than the number of points n?
The algorithm clamps to at most n−1 neighbours; effectively every point sees every other and you lose all locality, approaching a near-global (almost linear-projection-like) embedding.
Edge — What happens at the extremes of min_dist (0 versus close to 1)?
At min_dist=0 the kernel lets v→1 even as dlo→0, giving tight, dense clusters that preserve local density; near the upper end (approaching 1) points are strongly repelled at short range, producing an inflated, evenly spread layout that trades density info for readability.
Edge — What if the data is genuinely linear (a flat plane in high-D)?
UMAP will still work, but this is exactly the case where a linear method like PCA or Random Projection is cheaper and gives a faithful, interpretable result.
Edge — What if you feed UMAP a distance metric that violates the triangle inequality?
UMAP tolerates arbitrary metrics for graph construction, but the manifold assumption weakens; interpret the layout cautiously since the "geodesic" reasoning behind Isomap-style methods no longer holds cleanly.