Why is (3,9,4,2,1) more similar than (100,100,100,100,100)?

Do you mean (3,9,4,2,1) is more similar to (5,7,2,5,1) than (100,100,100,100,100) to (5,7,2,5,1)?

If you want some amount of similarity between two ordered sets, I would interpret them as vectors and look at the Cosine Similarity between the two. This will give you a measure for the "direction" of where the two vectors point, so you will likely also want to compare the length of the two vectors.

An alternative if your sets aren't really vectors would be to order them by size and compute the squared difference between each two numbers in the same place.

If your sets still are ordered but the cosine similarity doesn't give you equality when you want it would be to just calculate the squared difference between each of the set elements.


In reply to Re: Hashes: Find similar entries! by Corion
in thread Hashes: Find similar entries! by Trace On

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.