# Function Repository Resource:

# MultisetSokalSneathDissimilarity

Compute the Sokal–Sneath dissimilarity of two multisets

Contributed by: Robert B. Nachbar (Wolfram Solutions)
 ResourceFunction["MultisetSokalSneathDissimilarity"][list1,list2] gives the Sokal–Sneath dissimilarity between multisets list1 and list2. ResourceFunction["MultisetSokalSneathDissimilarity"][assoc1,assoc2] gives the Sokal–Sneath dissimilarity between multisets assoc1 and assoc2.

## Details and Options

If the listi are considered as multisets, MultisetSokalSneathDissimilarity gives their dissimilarity.
The listi must have the same head, but it need not be List.
The values of associ must be counts, that is, non-negative integer values.
ResourceFunction["MultisetSokalSneathDissimilarity"][A,B] is equivalent to .

## Examples

### Basic Examples

Sokal–Sneath dissimilarity between two List multisets:

 In:= Out= Sokal–Sneath dissimilarity between two Association multisets:

 In:= Out= ### Scope

The number of elements of each distinct kind affects the result:

 In:= Out= In:= Out= In:= Out= In:= Out= ### Applications

The Sokal–Sneath dissimilarity measure has its origins in numerical taxonomy. It was proposed by Robert R. Sokal and Peter H. A. Sneath as a measure of similarity in the same class as the Jaccard and Dice measures but with an alternative weighting of unmatched features.

The measure can be used in a number of fields, as shown by the following examples. The role of object and attribute can also be reversed, and the first application demonstrates this duality.

#### Ecology

Here are some ground-based animal index counts:

 In:= Out= Here the different blocks (habitats) are compared using the animals present as characters. The arrangement of the table in this manner originated in the field of psychology, and was later adopted by numerical taxonomy.

The MultisetSokalSneathDissimilarity distance matrix of the blocks:

 In:= Out= A Dendrogram showing how the blocks cluster:

 In:= Out= The preceding analysis that compares the columns of the table is known as a Q-type (deriving from early factor analysis studies in the area of psychology). Conversely, comparing the rows is known as an R-type analysis and in this case compares the animals. Begin by first transposing the data table:

 In:= Out= A Dendrogram shows that elephants and zebras, for example, are distributed similarly:

 In:= Out= #### Taxonomy

This application uses the chemical composition of flower parts from Hawaiian anthurium plants to classify different species and commercial cultivars. Load the data:

 In:= In:= Out= In:= Out= A Dendrogram shows the clustering of the species:

 In:= Out= A feature space plot can be made from the PrincipalComponents of the distance matrix:

 In:= Out= #### Sociology

This example compares households on a single city block using the composition of household members (head, wife, daughter, brother-in-law, etc.). The data was compiled from the 1920 US Census for the 300 block of Wyoming Ave., Buffalo, NY. The households are labeled by street number.

 In:= Out= The aggregate composition of the neighborhood:

 In:= Out= The distance matrix using MultisetDiceDissimilarity can be displayed with an ArrayPlot (note the presence of off-diagonal 0s colored yellow):

 In:= Out= The clustering of the households as shown by a Dendrogram:

 In:= Out= The 14 yellow-colored, off-diagonal 0s of the preceding distance matrix represent pairs of identical households. They also appear in the preceding dendrogram as leaves with no initial height. Here they are extracted as clusters:

 In:= In:= Out= Finally, mapping back to the original household data gives:

 In:= Out= #### Economics

Understanding market forces and characteristics of the competition are essential components of profitable business decisions. This example shows how shopping malls might be compared using the numbers of kinds of businesses in each. The data was collected from the websites of each mall using the self-reported number of businesses in each category. These malls are all managed by the same organization, so the categories can be assumed to be consistent.

 In:= Out= The distance matrix using MultisetDiceDissimilarity can be displayed with an ArrayPlot:

 In:= Out= The Dendrogram shows that The Mills at Jersey Gardens is very different from the others:

 In:= Out= #### Chemistry

Similarity analysis of chemical structures goes back to the original work of Carhart et al. at Lederle Laboratories. It is used extensively to search though chemical databases to find compounds of interest and to cluster chemical structures into similar groups.

Here is small set of entities from the ChemicalData collection:

 In:= Out= They can be converted into computable Molecule objects:

 In:= Out= These are the topological features that will characterize each chemical structure (they are not the same as those used by Carhart et al., but are easily computable with MoleculeValue):

 In:= Using Dataset, a searchable database can be made:

 In:= Out= Testosterone, for example, can be taken as the query molecule:

 In:= Out= In:= Out= In:= Out= ### Properties and Relations

Sokal–Sneath dissimilarity is bounded by 0 and 1:

 In:= Out= In:= Out= The result is the same as SokalSneathDissimilarity when the multisets are sets:

 In:= Out= In:= Out= 