liveBook · Manning

Distance matrix

A distance matrix is a square array whose entries represent pairwise distances or dissimilarities between objects, points, or vertices.

How 3 Manning books explain it

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.

Read how Statistics Slam Dunk explains distance matrix →

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.

Read how Modern C explains distance matrix →

Related concepts

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.