NeedlemanWunschSimilarity[u, v]
gives a number representing the Needleman-Wunsch similarity between strings or vectors u and v.

Details and OptionsDetails and Options

  • NeedlemanWunschSimilarity[u, v] finds an optimal global alignment between the elements of u and v, and returns the number of one-element matches.
  • For strings, setting the option IgnoreCase->True makes NeedlemanWunschSimilarity treat lowercase and uppercase letters as equivalent.
  • With the default setting SimilarityRules->Automatic, each match between two characters contributes to the total similarity score, while each mismatch, insertion, or deletion contributes .
  • The option GapPenalty specifies an additional cost to be subtracted from the similarity score for any run of insertions or deletions.

ExamplesExamplesopen allclose all

Basic Examples (2)Basic Examples (2)

Needleman-Wunsch similarity between two strings:

Click for copyable input

Needleman-Wunsch similarity between two vectors:

Click for copyable input
New in 7
New to Mathematica? Find your learning path »
Have a question? Ask support »