Distance matrix
A distance matrix is a square array whose entries represent pairwise distances or dissimilarities between objects, points, or vertices.
Build a Robo-Advisor with Python (From Scratch)
A distance matrix is a square array whose entries represent pairwise dissimilarities between objects.
- How it is used
- Prepares correlated assets for hierarchical clustering in hierarchical risk parity portfolio allocation.
- How deep it goes
- Derives two distance matrices and implements both calculations, then defers cluster formation to later steps.
- Examples
- Uses eight ETF-like tickers and Python calculations of correlations, distances, and pairwise vector norms.
- What you can do after
- Build it from scratch by converting return correlations into clustering-ready distance matrices in Python.
Read how Build a Robo-Advisor with Python (From Scratch) explains distance matrix →
Statistics Slam Dunk
A distance matrix is a tabular structure containing pairwise distances or dissimilarities between observations.
- How it is used
- Supports hierarchical clustering by quantifying similarity between observations.
- How deep it goes
- Works through Euclidean calculations, R output, and dendrogram construction.
- Examples
- Uses NBA draft pick numbers and average career win shares, including hand-calculated pairwise distances.
- What you can do after
- Apply it via R's dist() and hclust() functions to produce hierarchical clusters.
Modern C
A distance matrix is a matrix whose entry for a pair of points records the distance from the first point to the second.
- How it is used
- Supports shortest-path reasoning by storing distances between ordered pairs of points in a graph.
- How deep it goes
- Defines the representation and sentinel convention, then asks for shortest-path work without supplying an algorithm.
- Examples
- Uses graph G, ordered points i and j, nodes x and y, and SIZE_MAX for absent direct arcs.
- What you can do after
- Evaluate a graph representation and formulate a shortest-path search between two specified nodes.
Related concepts
- correlation matrixproduced by · A correlation matrix is a square matrix whose entries represent pairwise correlation coefficients among a set of variables.
- haversine formulaproduced by · The Haversine formula computes the great-circle distance between two points on a sphere from their latitudes and longitudes.
- objective functionused by · An objective function assigns values to candidate solutions, predictions, or parameter settings according to a criterion to be minimized or maximized.
- Euclidean distanceused by · Euclidean distance is the straight-line distance between two points in Euclidean space, calculated as the square root of the sum of squared differences between corresponding coordinates.
- dist() functionproduced by · The dist() function in base R computes pairwise distances between observations using a specified distance measure.
These guides are generated from the text of Manning books by Manning's knowledge graph and link to the sections they draw on. The full books are available on liveBook and at manning.com.


