手麻胳膊麻是什么原因引起的| 五月11号是什么星座| 雌二醇是什么| 孙膑是什么学派| 虫草能治什么病| 脚踝疼是什么原因| 唐僧是什么生肖| 朦胧是什么意思| 埋线是什么| 血压偏低有什么危害| 公章是什么样的| 花儿为什么这样红歌词| 4.5是什么星座| 血浆蛋白是什么| 孑孓什么意思| 指甲紫色是什么原因| 减脂晚上吃什么好| prime是什么意思| 80年出生属什么生肖| hcd是什么意思| 血红蛋白低吃什么可以补起来| 免疫缺陷是什么意思| 眼皮一直跳是什么原因| 乘载和核载是什么意思| 我们都没错只是不适合是什么歌| b票能开什么车| 梦到狗是什么意思| 三月七号是什么星座| 什么叫脑白质病| 肠胃感冒吃什么药最好| 为什么不能空腹吃香蕉| 梦见着火了是什么征兆| 月经两个月没来是什么原因| 干眼症用什么药最好| 四川大学校长什么级别| 标间是什么意思| 宁静是什么民族| 属兔的婚配什么属相好| 11月2号什么星座| 天梭表什么档次| 管教有方是什么意思| camouflage什么意思| 梦见老人去世预示什么| 尿分叉是什么原因| 春晓的晓是什么意思| 颌下淋巴结肿大吃什么药| 吃螃蟹不能吃什么| 二甲双胍是什么药| 脑梗前有什么预兆| 经常做噩梦是什么原因| 1954年出生属什么| 光是什么颜色| 吃什么增强记忆力| 头发油的快是什么原因| 118什么意思| 蜂蜜什么时间喝最好| 咳嗽喝什么药| tem是什么| 培根是什么肉做的| 梦见自己吃肉是什么预兆| 两个b型血能生出什么血型的孩子| 揩油是什么意思| 蓝痣有没有什么危害| 穆斯林不吃什么| 乌龟吃什么食物| 尿等待吃什么药最好| 什么是射精| 祛湿喝什么| 补气血吃什么食物| 梦见白萝卜是什么意思| 男人前列腺在什么位置| 什么话是世界通用的| 梦见网鱼是什么征兆| 嘴巴像什么| 眼睛发痒是什么原因| 阴道润滑剂什么牌子好| 龙什么鱼| uva是什么意思| 怎么看自己五行属什么| 筋膜刀是什么| 出离心是什么意思| 白带黄绿色是什么炎症| 女人什么时候最想男人| 点卯是什么意思| 小说be是什么意思| 心仪什么意思| 中风是什么| 8月6号什么星座| 糜米是什么米| 产检挂什么科| 大排畸主要检查什么| 用什么香皂洗脸可以祛痘| 血糖高吃什么可以降下来| 看灰指甲去医院挂什么科| 长期吃避孕药有什么危害| 先天性聋哑病属于什么遗传病| 什么时候洗头是最佳时间| 男人脚肿是什么病的前兆| 吐了后吃点什么能舒服| 气血不足吃什么药最好| 子宫平位是什么意思| 肠胃不好吃什么水果好| 梦见被警察抓预示什么| 减肥期间应该吃什么| 相表里什么意思| 牵牛花是什么颜色| 毓婷是什么| 湿热泄泻是什么意思| 太岁是什么| 呼吸道感染一般用什么消炎药| 2004年属猴的是什么命| 杜仲泡水喝有什么功效| 子不教父之过是什么意思| 鸡精和鸡粉有什么区别| 宫颈息肉有什么危害| 5月16日是什么星座| 蜈蚣代表什么生肖| 大便拉不干净是什么原因| 魂牵梦绕是什么意思| 猫能吃什么水果| 夏天脚开裂是什么原因| 人的运气跟什么有关| 麻鸡是什么鸡| 奥利司他排油是什么油| 天行健下一句是什么| 二月春风似剪刀的上一句是什么| 十一月十五号是什么星座| 仪态什么什么| 醪糟是什么东西| 互诉衷肠是什么意思| 去医院看乳房挂什么科| 1970年属狗的是什么命| 切除子宫对身体有什么影响| 洗面奶和洁面乳有什么区别| md是什么牌子| 仓鼠吃什么东西| 色盲是什么遗传方式| 毒灵芝长什么样| 混合性皮肤用什么护肤品比较好| 2月29日是什么星座| 拔罐出水是什么原因| 跳什么舞减肥最快| 2024是什么年| 小孩测骨龄挂什么科| 眼睛出现重影是什么原因| 胃炎吃什么中药效果好| 吃什么药怀孕最快| 孕妇为什么不能吃西瓜| 艺不压身是什么意思| 气虚什么症状| 什么血型是熊猫血| 血症是什么病| 法克是什么意思| egcg是什么| 有龙则灵的灵是什么意思| 区域经理的岗位职责是什么| 三什么一什么| 卦是什么意思| 铁观音茶属于什么茶| 兔子的耳朵有什么作用| 黑长直是什么意思| 鸭子是什么职业| bf是什么意思| 脑血管痉挛是什么原因引起的| 木加一笔有什么字| 大连焖子是什么做的| 幽门螺旋杆菌是什么病| 什么消炎药最好| N医学上是什么意思| 打歌是什么意思| wbc是什么意思医学| 牛三合生肖是什么| 睡觉打呼噜是什么原因| 金银花洗澡对婴儿有什么好处| 怀孕吃什么好| 吃什么东西可以除湿气| 肛裂是什么感觉| 褒义词是什么意思| 眼睛有眼屎是什么原因| peek是什么材质| 宫外孕有什么症状| 一月27日是什么星座| 冷都男是什么意思| 人为什么会打哈欠| 淋病挂什么科| 普瑞巴林胶囊治什么病| 什么是复韵母| 海蓝宝五行属什么| 梦见玫瑰花是什么预兆| sec是什么意思| adh医学上是什么意思| 多汗症是什么原因| 胃疼吃什么药| 肾疼是因为什么| 一什么黑板| 为什么会肚子痛| 什么地流| 戒的部首是什么| 什么是膝关节退行性变| 总想睡觉是什么原因| 膀胱炎做什么检查能看出来| faleda是什么牌子的手表| 耳朵响是什么原因引起的| 痔疮的初期症状是什么| 大便呈绿色是什么原因| 冒冷汗是什么原因| 什么时候种胡萝卜最好| 做梦梦见蛇是什么意思| 什么是房补| 女性为什么会肾结石| 为什么会来月经| 怀不上孕做什么检查| 为什么会肾结石| pu是什么元素| cr是什么意思| 头发大把大把的掉是什么原因| 怀孕吃什么有营养| 诗意是什么意思| 身宫是什么意思| 冬枣为什么叫冬枣| 哺乳期头痛可以吃什么药| 声带白斑是什么病严重吗| 栀子花什么时候修剪| 千里莺啼什么映什么| 跳蚤长什么样子| 一个合一个页读什么| 山羊吃什么| 爱情是什么样| 荔枝适合什么地方种植| 救星是什么意思| 解除是什么意思| 109是什么意思| 血糖高一日三餐吃什么东西最适合| 日本牛郎是干什么的| 气血不足吃什么补最快| 脚麻木吃什么药| 28岁属什么的| 0和1是什么意思| 麦粒肿滴什么眼药水| 24k镀金是什么意思| 嘴唇发紫是什么原因| 去脂体重什么意思| 聪明的人有什么特征| 木薯淀粉可以用什么代替| 宫颈炎吃什么药效果最好| 结膜炎滴什么眼药水| hcg是什么激素| 黑匣子什么颜色| 做梦梦见前男友是什么意思| 梦见背死人是什么意思| 双离合是什么意思| 什么球不能踢脑筋急转弯| 男人吃女人有什么好处| 怀孕后期脚肿是什么原因| 公立医院和私立医院有什么区别| 男士内裤买什么牌子好| 肺有问题挂什么科| 下眼袋浮肿是什么原因| 数据中心是什么| 利可君片是什么药| icu是什么意思| 女孩为什么难得午时贵| 为什么地球是圆的| 中戏是什么学校| 百度Jump to content

胸腔积液叩诊什么音

From Wikipedia, the free encyclopedia
百度   负责党的纪律执行、党内监督等工作;负责党风廉政建设工作。

Hamming distance
4-bit binary tesseract
4-bit binary tesseract for finding Hamming distance.
4-bit binary tesseract Hamming distance examples
Two example distances: 0100→1001 has distance 3; 0110→1110 has distance 1
ClassString similarity
Data structurestring
Worst-case performance
Best-case performance
Average performance
Worst-case space complexity
3-bit binary cube
3-bit binary cube for finding Hamming distance
3-bit binary cube Hamming distance examples
Two example distances: 100→011 has distance 3; 010→111 has distance 2
The minimum distance between any two vertices is the Hamming distance between the two binary strings.

In information theory, the Hamming distance between two strings or vectors of equal length is the number of positions at which the corresponding symbols are different. In other words, it measures the minimum number of substitutions required to change one string into the other, or equivalently, the minimum number of errors that could have transformed one string into the other. In a more general context, the Hamming distance is one of several string metrics for measuring the edit distance between two sequences. It is named after the American mathematician Richard Hamming.

A major application is in coding theory, more specifically to block codes, in which the equal-length strings are vectors over a finite field.

Definition

[edit]

The Hamming distance between two equal-length strings of symbols is the number of positions at which the corresponding symbols are different.[1]

Examples

[edit]

The symbols may be letters, bits, or decimal digits, among other possibilities. For example, the Hamming distance between:

  • "karolin" and "kathrin" is 3.
  • "karolin" and "kerstin" is 3.
  • "kathrin" and "kerstin" is 4.
  • 0000 and 1111 is 4.
  • 2173896 and 2233796 is 3.

Properties

[edit]

For a fixed length n, the Hamming distance is a metric on the set of the words of length n (also known as a Hamming space), as it fulfills the conditions of non-negativity, symmetry, the Hamming distance of two words is 0 if and only if the two words are identical, and it satisfies the triangle inequality as well:[2] Indeed, if we fix three words a, b and c, then whenever there is a difference between the ith letter of a and the ith letter of c, then there must be a difference between the ith letter of a and ith letter of b, or between the ith letter of b and the ith letter of c. Hence the Hamming distance between a and c is not larger than the sum of the Hamming distances between a and b and between b and c. The Hamming distance between two words a and b can also be seen as the Hamming weight of a ? b for an appropriate choice of the ? operator, much as the difference between two integers can be seen as a distance from zero on the number line.[clarification needed]

For binary strings a and b the Hamming distance is equal to the number of ones (population count) in a XOR b.[3] The metric space of length-n binary strings, with the Hamming distance, is known as the Hamming cube; it is equivalent as a metric space to the set of distances between vertices in a hypercube graph. One can also view a binary string of length n as a vector in by treating each symbol in the string as a real coordinate; with this embedding, the strings form the vertices of an n-dimensional hypercube, and the Hamming distance of the strings is equivalent to the Manhattan distance between the vertices.

Error detection and error correction

[edit]

The minimum Hamming distance or minimum distance (usually denoted by dmin) is used to define some essential notions in coding theory, such as error detecting and error correcting codes. In particular, a code C is said to be k error detecting if, and only if, the minimum Hamming distance between any two of its codewords is at least k+1.[2]

For example, consider a code consisting of two codewords "000" and "111". The Hamming distance between these two words is 3, and therefore it is k=2 error detecting. This means that if one bit is flipped or two bits are flipped, the error can be detected. If three bits are flipped, then "000" becomes "111" and the error cannot be detected.

A code C is said to be k-error correcting if, for every word w in the underlying Hamming space H, there exists at most one codeword c (from C) such that the Hamming distance between w and c is at most k. In other words, a code is k-errors correcting if the minimum Hamming distance between any two of its codewords is at least 2k+1. This is also understood geometrically as any closed balls of radius k centered on distinct codewords being disjoint.[2] These balls are also called Hamming spheres in this context.[4]

For example, consider the same 3-bit code consisting of the two codewords "000" and "111". The Hamming space consists of 8 words 000, 001, 010, 011, 100, 101, 110 and 111. The codeword "000" and the single bit error words "001","010","100" are all less than or equal to the Hamming distance of 1 to "000". Likewise, codeword "111" and its single bit error words "110","101" and "011" are all within 1 Hamming distance of the original "111". In this code, a single bit error is always within 1 Hamming distance of the original codes, and the code can be 1-error correcting, that is k=1. Since the Hamming distance between "000" and "111" is 3, and those comprise the entire set of codewords in the code, the minimum Hamming distance is 3, which satisfies 2k+1 = 3.

Thus a code with minimum Hamming distance d between its codewords can detect at most d-1 errors and can correct ?(d-1)/2? errors.[2] The latter number is also called the packing radius or the error-correcting capability of the code.[4]

History and applications

[edit]

The Hamming distance is named after Richard Hamming, who introduced the concept in his fundamental paper on Hamming codes, Error detecting and error correcting codes, in 1950.[5] Hamming weight analysis of bits is used in several disciplines including information theory, coding theory, and cryptography.[6]

It is used in telecommunication to count the number of flipped bits in a fixed-length binary word as an estimate of error, and therefore is sometimes called the signal distance.[7] For q-ary strings over an alphabet of size q ≥ 2 the Hamming distance is applied in case of the q-ary symmetric channel, while the Lee distance is used for phase-shift keying or more generally channels susceptible to synchronization errors because the Lee distance accounts for errors of ±1.[8] If or both distances coincide because any pair of elements from or differ by 1, but the distances are different for larger .

The Hamming distance is also used in systematics as a measure of genetic distance.[9]

However, for comparing strings of different lengths, or strings where not just substitutions but also insertions or deletions have to be expected, a more sophisticated metric like the Levenshtein distance is more appropriate.

Algorithm example

[edit]

The following function, written in Python 3, returns the Hamming distance between two strings:

def hamming_distance(string1: str, string2: str) -> int:
    """Return the Hamming distance between two strings."""
    if len(string1) != len(string2):
        raise ValueError("Strings must be of equal length.")
    dist_counter = 0
    for n in range(len(string1)):
        if string1[n] != string2[n]:
            dist_counter += 1
    return dist_counter

Or, in a shorter expression:

sum(char1 != char2 for char1, char2 in zip(string1, string2, strict=True))

The function hamming_distance(), implemented in Python 3, computes the Hamming distance between two strings (or other iterable objects) of equal length by creating a sequence of Boolean values indicating mismatches and matches between corresponding positions in the two inputs, then summing the sequence with True and False values, interpreted as one and zero, respectively.

def hamming_distance(s1: str, s2: str) -> int:
    """Return the Hamming distance between equal-length sequences."""
    if len(s1) != len(s2):
        raise ValueError("Undefined for sequences of unequal length.")
    return sum(char1 != char2 for char1, char2 in zip(s1, s2))

where the zip() function merges two equal-length collections in pairs.

The following C function will compute the Hamming distance of two integers (considered as binary values, that is, as sequences of bits). The running time of this procedure is proportional to the Hamming distance rather than to the number of bits in the inputs. It computes the bitwise exclusive or of the two inputs, and then finds the Hamming weight of the result (the number of nonzero bits) using an algorithm of Wegner (1960) that repeatedly finds and clears the lowest-order nonzero bit. Some compilers support the __builtin_popcount function which can calculate this using specialized processor hardware where available.

int hamming_distance(unsigned x, unsigned y)
{
    int dist = 0;

    // The ^ operators sets to 1 only the bits that are different
    for (unsigned val = x ^ y; val > 0; ++dist)
    {
        // We then count the bit set to 1 using the Peter Wegner way
        val = val & (val - 1); // Set to zero val's lowest-order 1
    }

    // Return the number of differing bits
    return dist;
}

A faster alternative is to use the population count (popcount) assembly instruction. Certain compilers such as GCC and Clang make it available via an intrinsic function:

// Hamming distance for 32-bit integers
int hamming_distance32(unsigned int x, unsigned int y)
{
    return __builtin_popcount(x ^ y);
}

// Hamming distance for 64-bit integers
int hamming_distance64(unsigned long long x, unsigned long long y)
{
    return __builtin_popcountll(x ^ y);
}

See also

[edit]

References

[edit]
  1. ^ Waggener, Bill (1995). Pulse Code Modulation Techniques. Springer. p. 206. ISBN 978-0-442-01436-0. Retrieved 13 June 2020.
  2. ^ a b c d Robinson, Derek J. S. (2003). An Introduction to Abstract Algebra. Walter de Gruyter. pp. 255–257. ISBN 978-3-11-019816-4.
  3. ^ Warren Jr., Henry S. (2013) [2002]. Hacker's Delight (2 ed.). Addison WesleyPearson Education, Inc. pp. 81–96. ISBN 978-0-321-84268-8. 0-321-84268-5.
  4. ^ a b Cohen, G.; Honkala, I.; Litsyn, S.; Lobstein, A. (1997), Covering Codes, North-Holland Mathematical Library, vol. 54, Elsevier, pp. 16–17, ISBN 978-0-08-053007-9
  5. ^ Hamming, R. W. (April 1950). "Error detecting and error correcting codes" (PDF). The Bell System Technical Journal. 29 (2): 147–160. doi:10.1002/j.1538-7305.1950.tb00463.x. hdl:10945/46756. ISSN 0005-8580. S2CID 61141773. Archived (PDF) from the original on 2025-08-05.
  6. ^ Jarrous, Ayman; Pinkas, Benny (2009). "Secure Hamming Distance Based Computation and Its Applications". In Abdalla, Michel; Pointcheval, David; Fouque, Pierre-Alain; Vergnaud, Damien (eds.). Applied Cryptography and Network Security. Lecture Notes in Computer Science. Vol. 5536. Berlin, Heidelberg: Springer. pp. 107–124. doi:10.1007/978-3-642-01957-9_7. ISBN 978-3-642-01957-9.
  7. ^ Ayala, Jose (2012). Integrated Circuit and System Design. Springer. p. 62. ISBN 978-3-642-36156-2.
  8. ^ Roth, Ron (2006). Introduction to Coding Theory. Cambridge University Press. p. 298. ISBN 978-0-521-84504-5.
  9. ^ Pilcher, Christopher D.; Wong, Joseph K.; Pillai, Satish K. (2025-08-05). "Inferring HIV Transmission Dynamics from Phylogenetic Sequence Relationships". PLOS Medicine. 5 (3): e69. doi:10.1371/journal.pmed.0050069. ISSN 1549-1676. PMC 2267810. PMID 18351799.

Further reading

[edit]
舌头麻是什么病的前兆 糖吃多了有什么危害 alds是什么病 带牙套是什么意思 hbv是什么病毒
宁夏有什么特产 干咳无痰是什么原因引起的 整个后背疼是什么原因 马超属什么生肖 七四年属什么生肖
股票五行属什么 牛什么饭 1975年属兔的是什么命 狗能吃什么水果 排便困难是什么原因
恶性贫血是什么意思 经常出汗是什么原因 气胸是什么意思 输卵管堵塞是什么原因 早日康复送什么花
吃什么养肝护肝效果最好hcv8jop6ns7r.cn 多愁善感什么意思hcv9jop2ns1r.cn 什么是cdhcv8jop5ns3r.cn 木瓜什么时候成熟hcv9jop5ns0r.cn 方脸适合什么发型qingzhougame.com
意淫是什么mmeoe.com 醋泡黑豆有什么功效youbangsi.com 人见人爱是什么生肖gangsutong.com 直肠窝积液是什么意思hcv8jop3ns8r.cn 糯米是什么米hcv8jop1ns4r.cn
什么花代表永恒的爱hcv9jop6ns6r.cn 少许纤维灶是什么意思hcv8jop1ns7r.cn 阿迪达斯和三叶草有什么区别hcv9jop1ns0r.cn 什么什么鼎沸travellingsim.com 感染艾滋病有什么症状hcv8jop1ns0r.cn
什么是精神分裂hcv9jop8ns3r.cn 平均血小板体积偏高是什么原因luyiluode.com 五常法指的是什么hcv8jop5ns5r.cn hb是什么hcv8jop9ns1r.cn 半夜尿多是什么原因hcv8jop9ns4r.cn
百度