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 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.
Past exam of the mathematics course of the University of Cambridge 2007 iii Paper 47 4 b i Solution Created 2026-10-03 Updated 2026-10-14
For fixed , the complement of the simple matching coefficient is the fraction of coordinates that disagree:This is the normalized Hamming distance. It is nonnegative, symmetric, and is zero exactly when every coordinate agrees. At each coordinate,Summing and dividing by proves the triangle inequality. Therefore is a metric on the binary vectors.
Past exam of the mathematics course of the University of Cambridge 2007 iii Paper 47 4 b Solution 2026-10-14
A metric dissimilarity must satisfy, for all , the four propertiesThey are nonnegativity, identity of indiscernibles, symmetry and the triangle inequality. The following two transformations of the simple matching coefficient behave differently at the identity.
