2 ms·
generally, popcnt is useful to implement the Jaccard Distance [1]: J(X,Y) = |X∩Y| / |X∪Y| So, implementing the sets X and Y as bitsets it becomes: [1]: h
by gpderetta 7y ago
generally, popcnt is useful to implement the Jaccard Distance [1]:
J(X,Y) = |X∩Y| / |X∪Y|
So, implementing the sets X and Y as bitsets it becomes:
[1]: https://en.wikipedia.org/wiki/Jaccard_index https://en.wikipedia.org/wiki/Jaccard_index
J(X,Y) = popcnt(X&Y) / popcnt(X|Y)
- dalke 7y agoIf anyone needs that to go fast, for fixed-length (up to ~4k bits) try out my code, chemfp at http://chemfp.com/ http://chemfp.com/ . It's designed for cheminformatics, but can work with any data set which can be described by a fixed-length byte string and an identifier.