Jaccard index 2026-10-14
The index measures similarity of finite sets by shared presence relative to total presence. For binary profiles it ignores joint absences, unlike the simple matching coefficient. When both sets are empty, define the similarity to be one. The complementary Jaccard distance measures dissimilarity.
Past exam of the mathematics course of the University of Cambridge 2003 iii Paper 42 2 ii Solution Created 2026-10-03 Updated 2026-10-14
The output describes complete-linkage clustering: the distance between two current groups is the largest original Jaccard distance between a member of one and a member of the other. Starting with singleton groups, agglomerative hierarchical clustering merges a closest pair at each step. In the merge array, a negative index denotes the original row of that number, and a positive index denotes the group created at that earlier merge. A printed height is the dissimilarity at which the new group forms.
Reading those references recursively gives the following dendrogram construction, with exact heights recovered from the binary profiles:
- Fred and Gbenga join at ; Graham and Tim join at ; Chad and Nicolas join at .
- Frederic joins Chad–Nicolas at , and John then joins that group at the same height . These tied heights produce successive branches on the same horizontal level.
- Philip and Mark join at ; Garfield joins Fred–Gbenga at .
- Graham–Tim joins Philip–Mark at ; Chad–Nicolas–Frederic–John joins Garfield–Fred–Gbenga at .
- Sauli joins Graham–Tim–Philip–Mark at , and Juliet joins that group at .
- The two remaining groups join at .
Complete-linkage dendrogram reconstructed from exact binary-profile distances
. Details. For example, a cut strictly between and gives four groups: Chad–Nicolas–Frederic–John–Garfield–Fred–Gbenga, Graham–Tim–Philip–Mark, Sauli, and Juliet. A cut strictly between and gives two larger groups. The leaf order is not intrinsic; the merge memberships and heights are. Reflecting branches leaves the dendrogram unchanged in meaning. The zero-height pair indicates identical recorded responses, while high joins indicate comparatively dissimilar profiles. These conclusions depend on the choice of Jaccard distance, which ignores shared negative answers; the dendrogram itself does not establish substantive demographic classes.
Past exam of the mathematics course of the University of Cambridge 2003 iii Paper 42 2 i Solution Created 2026-10-03 Updated 2026-10-14
Treat each row as a set of attributes with response one. The binary option computes the Jaccard distance, rather than counting matches at joint absences. For a pair of rows, let count coordinates equal to one in both, count , count , and count . ThenThe denominator counts coordinates present in at least one row; joint absences do not contribute. If both rows have no presences, use distance zero. This differs from normalized Hamming distance, which would divide by all ten coordinates.
For Philip and Chad, four attributes are present in both and eight in at least one, giving Jaccard distance . Graham and Tim differ in one of eight coordinates present in their union, giving , printed as . Fred and Gbenga have identical profiles, hence distance zero despite being different students. The resulting dissimilarity matrix is symmetric with zero diagonal;
dist2full restores the other half and the diagonal from the stored pairwise entries. The display rounds entries for readability; the agglomerative hierarchical clustering uses the original unrounded distances. Past exam of the mathematics course of the University of Cambridge 2004 iii Paper 43 3 Solution Created 2026-10-03 Updated 2026-10-14
The first command reads a rectangular data file into
a; header=T treats the first line as variable names. There are twelve observations, identified by student names, and nine binary attributes. A one records presence of an attribute and a zero records absence. This is a description of the encoding, not a claim that every presence is equally important for a scientific application.dist(a, metric="binary") compares rows using Jaccard distance. If counts shared presences and count mismatched presences, thenJoint absences do not enter the denominator, unlike the simple matching coefficient or normalized Hamming distance. dist2full(d) expands the stored pairwise distances into a symmetric dissimilarity matrix; round(...,2) changes only its displayed precision. The clustering command still receives the original unrounded distances.For example, Tom and Martin have six shared presences and only one mismatch, giving . Taeko and Luitgard have three shared presences and four mismatches, giving . LingChen and Mohammad share only the meat attribute and differ on four others, giving . The diagonal is zero, and the entries are symmetric because exchanging the two observations exchanges and .
hclust(d, method="compact") constructs an agglomerative hierarchical clustering object by complete-linkage clustering. Its distance between two current groups isStart with singleton groups, merge a pair with smallest intergroup distance, update these maximum cross-pair distances, and repeat until one group remains. The object stores the merge structure, merge heights and a leaf order suitable for a dendrogram; assigning it to h does not itself display a graph. The historical S-Plus help identifies compact with complete linkage and describes the plotting object.The first merge is Tom with Martin at . At the next height , either LinYee with HuiChin or HuiChin with Meg may merge: the distances are tied. The following dendrogram shows one valid resolution, using original row order to resolve ties. In this tree, LinYee joins HuiChin at , Pio joins Meg at , and Nicolas joins Tom–Martin at . The latter height is , illustrating the complete-linkage update.
Complete-linkage dendrogram and Jaccard-distance heatmap for the binary student profiles, with one valid tie convention
. Details. For the displayed tree, a cut at height gives three groups: Taeko–Luitgard; Alet–Tom–Martin–Nicolas–Mohammad; and LinYee–Pio–LingChen–HuiChin–Meg. The last two merges occur at and . The hierarchy is a description under the chosen binary distance and linkage rule; it neither supplies an intrinsically correct number of groups nor guarantees a unique tree in the presence of ties. Changing the treatment of joint absences, or the weighting of attributes, can change that description.
Past exam of the mathematics course of the University of Cambridge 2006 iii Paper 46 4 b Solution Created 2026-10-03 Updated 2026-10-14
A metric dissimilarity must satisfy nonnegativity, separation, symmetry and the triangle inequality:The underlying objects must be specified: here they are binary measurement profiles, rather than labels attached to individuals.
Let count coordinate pairs of the indicated types. The simple matching coefficient is , so its complementary dissimilarity is . Counting mismatches in every pair gives the dissimilarity matrixFor the Jaccard coefficient, joint absences are excluded: . Thus the Jaccard distance is , givingOnly the pair of individuals two and four has a joint absence. Their profiles have one shared presence, two mismatched presences and one joint absence, giving dissimilarities and , respectively. All other pairs have a presence in at least one profile at every coordinate, so the two denominators coincide.
For the requested metric property of simple matching dissimilarity, write a general pair of -coordinate binary profiles as . Thenwhich is the normalized Hamming distance. It is nonnegative and symmetric, and equals zero exactly when all coordinates match. For each coordinate, a mismatch between and forces a mismatch between or between . ThereforeSumming and dividing by proves the triangle inequality, establishing all four metric properties. Simple matching dissimilarity is a metric on binary profiles. If two separately labelled individuals have identical profiles, it gives zero distance between them, so on those labels it is only a pseudometric. The four profiles here are distinct, so this distinction does not prevent from defining a metric on the given sample.

