algorithm - 如何确定 6 + 1 位数字的最大纠错/检测方法?

标签 algorithm error-correction

对于从图像中识别的数字,我有以下限制:

  • 6 位数据
  • 1 位错误修正
  • 前 6 位数字无法更改(它们必须是人类可读的)
  • 校验位必须保留数字

目前的纠错方案基于校验和,因此第 7 位数字是前 6 位数字之和的最后一位数字。

例如

123456 => 1234561
999999 => 9999994
472912 => 4729125
219274 => 2192745

我如何确定该方案可以检测/纠正的错误的数量和类型,是否有一个方案可以提供更好的错误检测? (对于我的用例来说,错误检测比错误纠正更重要)。

最佳答案

您可以尝试Luhn ,它比你描述的要复杂一点,但它会满足你的要求。

来自维基百科的复制粘贴:

The Luhn algorithm will detect any single-digit error, as well as almost all transpositions of adjacent digits. It will not, however, detect transposition of the two-digit sequence 09 to 90 (or vice versa). It will detect 7 of the 10 possible twin errors (it will not detect 22 ↔ 55, 33 ↔ 66 or 44 ↔ 77).

Other, more complex check-digit algorithms (such as the Verhoeff algorithm and the Damm algorithm) can detect more transcription errors. The Luhn mod N algorithm is an extension that supports non-numerical strings.

Because the algorithm operates on the digits in a right-to-left manner and zero digits affect the result only if they cause shift in position, zero-padding the beginning of a string of numbers does not affect the calculation. Therefore, systems that pad to a specific number of digits (by converting 1234 to 0001234 for instance) can perform Luhn validation before or after the padding and achieve the same result.

Prepending a 0 to odd-length numbers enables you to process the number from left to right rather than right to left, doubling the odd-place digits.

The algorithm appeared in a US Patent for a hand-held, mechanical device for computing the checksum. It was therefore required to be rather simple. The device took the mod 10 sum by mechanical means. The substitution digits, that is, the results of the double and reduce procedure, were not produced mechanically. Rather, the digits were marked in their permuted order on the body of the machine.

关于algorithm - 如何确定 6 + 1 位数字的最大纠错/检测方法?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14084965/

相关文章:

algorithm - 如何使用边界矩形纠正 OCR 分割错误?

c++ - 在 C++ 中使用递归将表达式括起来以获得最小结果

algorithm - 如何在仅使用一次元素对的同时(有效地)生成不相交的集合?

倒排索引搜索算法

c - 如何更改 I/O 格式?

c++ - C++中程序显示的意外输出

python 相关单词搜索并替换为列表单词

algorithm - 在简单的线性数据集中查找并修复错误值

algorithm - OCR纠错: How to combine three erroneous results to reduce errors

algorithm - 减少图表上的数据点?