套餐二位序列之间快速确定相似性 [英] Package for fast determination of similarity between two bit sequences

查看:119
本文介绍了套餐二位序列之间快速确定相似性的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要多达一百万比特序列的数据库进行比较的查询位序列。所有位序列是100位长。我需要的查找,以尽可​​能快。是否有任何包在那里进行快速测定两位序列之间的相似性? - 编辑 - 位序列位置敏感。

I need to compare a query bit sequence with a database of up to a million bit sequences. All bit sequences are 100 bits long. I need the lookup to be as fast as possible. Are there any packages out there for fast determination of the similarity between two bit sequences? --Edit-- The bit sequences are position sensitive.

我看到一个可能算法位操作黑客但如果有是一个现成的包,效果会更好。

I have seen a possible algorithm on Bit Twiddling Hacks but if there is a ready made package that would be better.

推荐答案

如果你想查找,假设50,最匹配的模式,我们可以假设输入数据集是相当静态的(或者可以动态更新),可以重复previous注释的初始阶段,因此:

If you want to look up the, let's say 50, most matching patterns, and we can assume that the input data set is rather static (or can be dynamically updated), you can repeat the initial phase of the previous comment, so:


  • 对于每一个位模式,计数位。

  • 存放在multi_map的位模式(如果你使用STL,Java的可能有类似的东西)

然后,使用下面的算法:

Then, use the following algorithm:


  • 请收藏2:一个用于储存中发现的模式,一个用于存储可能是很好的模式(本次集合也许应该是地图,地图'距离',以图案)

  • 把你自己的模式和计数位,假设这是N

  • 查找multimap中索引N,所有这些模式将具有相同的总和,但不一定完全一致

  • 比较索引N.所有的模式。如果他们是平等的店,结果第一个收藏。如果它们不相等,则结果存储在第二收集/图,使用该差作为关键。

  • 查找multimap中索引N-1,所有这些模式将有1个或多个
  • 的距离
  • 在指数N-1比较所有的模式。如果它们具有1的距离,将它们存储在第一收藏。如果他们有一个较大的距离,结果存储在第二收集/图,使用该差作为关键。

  • 重复索引N + 1

  • 现在,看看在第二收集/地图,看看是否有存储与距离1东西,如果是这样,从第二收集/地图删除它们,并将它们存储第一个收藏。

重复此距离为2,距离3,......直到你有足够的模式。

Repeat this for distance 2, distance 3, ... until you have enough patterns.

如果需要模式的数目并不太大,平均距离也不能太大,则实数模式之间的比较可能是只有百分之几。

If the number of required patterns is not too big, and the average distance is also not too big, then the number of real compares between patterns is probably only a few %.

不幸的是,由于模式将使用高斯曲线分布,仍然会有相当一些模式进行检查。我没有做一个数学检查就可以了,但在实践中,如果你不想太多的图案了数以百万计的,平均距离不是太远,你应该能够找到一套最密切的通过检查只是总位模式的百分之几的图案。

Unfortunately, since the patterns will be distributed using a Gaussian curve, there will still be quite some patterns to check. I didn't do a mathematical check on it, but in practice, if you don't want too many patterns out of the millions, and the average distance is not too far, you should be able to find the set of most-close patterns by checking only a few percent of the total bit patterns.

请让我了解你的结果。

这篇关于套餐二位序列之间快速确定相似性的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆