Also known as (7,4) code,7 trainsmitted bits for 4 source code.

TRANSMIT

The transmitted procedure can be reprecented as follows.

$t=G^Ts$

where G is:

import numpy as np
G = np.matrix(
[[1,0,0,0],
[0,1,0,0],
[0,0,1,0],
[0,0,0,1],
[1,1,1,0],
[0,1,1,1],
[1,0,1,1]]).T
s=np.matrix([[1,1,1,0]]).T t = (G.T*s)%2

visualization

$t_5,t_6,t_7$ is called parity-check bits

----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

DECODING

1.intuitive way: measure the similarity between the recieved bits $r$ and the encoded codes $t$

2.Syndrome decoding

dashed line for which parity is not even(unhappy)

full line for which parity is even(happy)

find the unique bit,that lies inside all unhappy circles and outside all happy circles

the corresponding syndrome z as follow:

(b) 110 ($t_5$ not even,$t_6$ not even,$t_7$ even),$r_2$ should be unflipped

(c) 100 ($t_5$ not even,$t_6$ even,$t_7$ even),$r_5$ should be unflipped

(d) 111 ($t_5$ not even,$t_6$ not even,$t_7$ not even),$r_3$ should be unflipped

all the situations is listed in table below:

the syndrome z can be achieved by matrix:

$z=Hr$

which H is:

----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

PERFORMANCE

1.when there is only one bit flipped in all 7 bits,the decoder can always get right

2.when there are more than one bits flippend,the decoder get wrong

the single bit error rate,can be estimate as follow:

$p_b \approx \frac{1-{(1-f)}^2-7{(1-f)}^6f}{2}$

the exact error rate is about 0.6688,which can be computed with following program.

 import numpy as np
import copy
import itertools
from scipy.misc import comb def encode(s):
G = np.array(
[[1,0,0,0],
[0,1,0,0],
[0,0,1,0],
[0,0,0,1],
[1,1,1,0],
[0,1,1,1],
[1,0,1,1]]
) return np.dot(G,s)%2 def decode(r):
t_hat = copy.deepcopy(r)
H = np.array(
[[1,1,1,0,1,0,0],
[0,1,1,1,0,1,0],
[1,0,1,1,0,0,1]]
) syndrome_map = {0:-1,
1:6,
10:5,
11:3,
100:4,
101:0,
110:1,
111:2} syndrome = np.dot(np.dot(H,r)%2,np.array([100,10,1]))
if syndrome_map[syndrome]>=0:
t_hat[syndrome_map[syndrome]] = (t_hat[syndrome_map[syndrome]]+1)%2 return t_hat def flipn(flip_list,t):
'''
flipped the bits specified by flip_list and return it
:param flip_list:
:param t:
:return:
'''
r = copy.deepcopy(t)
for flip in flip_list:
r[flip] = (r[flip]+1)%2
return r def flipn_avg_err(n,s):
'''
get the average error bits when flip n bits
:param n:
:param s:
:return:
'''
t = encode(s)
items = range(7)
errors = 0
count = 0
for flip in itertools.combinations(items,n):
r = flipn(list(flip),t)
t_hat = decode(r) errors += 4-sum(s==t_hat[:4])
count += 1
return errors*1.0/count f = 0.9
s = np.array([0,0,0,0])
all_error = 0.0
for n in range(2,8):
error = flipn_avg_err(n,s)
all_error += error*comb(7,n)*(f**(7-n))*((1-f)**n)
print all_error/4

python

Hamming code的更多相关文章

  1. URAL 1792. Hamming Code (枚举)

    1792. Hamming Code Time limit: 1.0 second Memory limit: 64 MB Let us consider four disks intersectin ...

  2. 汉明码(Hamming Code)原理及实现

    汉明码实现原理 汉明码(Hamming Code)是广泛用于内存和磁盘纠错的编码.汉明码不仅可以用来检测转移数据时发生的错误,还可以用来修正错误.(要注意的是,汉明码只能发现和修正一位错误,对于两位或 ...

  3. 汉明码(hamming code)

    hamming code用于磁盘RAID 2中, 关于汉明码的讲解可以看这篇博文,介绍的很详细.最重要是最后的结论: 汉明码属于分组奇偶校验,P4P2P1=000,说明接收方生成的校验位和收到的校验位 ...

  4. 汉明码、海明校验码(Hamming Code)

    目录 基础知识 汉明码/海明校验码 计算 基础知识 码距:又叫海明距离,是在信息编码中,两个编码之间对应位上编码不同的位数.例如编码100110和010101,第1.2.5.6位都不相同,所以这两个编 ...

  5. Google Interview University - 坚持完成这套学习手册,你就可以去 Google 面试了

    作者:Glowin链接:https://zhuanlan.zhihu.com/p/22881223来源:知乎著作权归作者所有.商业转载请联系作者获得授权,非商业转载请注明出处. 原文地址:Google ...

  6. 什么是RAID

    RAID 维基百科,自由的百科全书 关于与「 RAID 」同名的其他主题,详见「 RAID (消歧义) 」. 独立硬盘冗余阵列 ( RAID , R edundant A rray of I ndep ...

  7. 关于硬盘和几种RAID

    1 硬盘的基本工作原理 1.1 硬盘部件结构图 1.2 主要参数术语解释 磁头:在与硬盘交换数据的过程 中,读操作远远快于写操作,硬盘厂商开发一种读/写分离磁头. 转速(Rotationl Speed ...

  8. ECC校验优化之路

    引子: 今天上嵌入式课程时,老师讲到Linux的文件系统,讲的重点是Linux中对于nand flash的ECC校验和纠错.上课很认真地听完,确实叹服代码作者的水平. 晚上特地下载了Linux最新的内 ...

  9. 独立硬盘冗余阵列与HDFS

    http://zh.wikipedia.org/wiki/RAID 独立硬盘冗余阵列(RAID, Redundant Array of Independent Disks),旧称廉价磁盘冗余阵列(Re ...

随机推荐

  1. 3Sum Smaller 解答

    Question Given an array of n integers nums and a target, find the number of index triplets i, j, k w ...

  2. linux group

    groups 查看当前登录用户的组内成员 groups gliethttp 查看gliethttp用户所在的组,以及组内成员 whoami 查看当前登录用户名   /etc/group文件包含所有组 ...

  3. C#使用自定义字体(从文件获取)

    在进行软件开发,尤其是开发WinForm程序时,有时为了实现界面的美化,不可避免的需要使用一些特殊的字体,但是在开发完成之后,将程序移到其他的机器上时,由于这些机器可能没有安装相应的字体,所以整个界面 ...

  4. 编程算法 - 圆圈中最后剩下的数字(递推公式) 代码(C++)

    圆圈中最后剩下的数字(递推公式) 代码(C++) 本文地址: http://blog.csdn.net/caroline_wendy 题目: 0,1...,n-1这n个数字排成一个圆圈, 从数字0開始 ...

  5. Oracle安装基本步骤

    安装数据库 .建立用户组及用户 groupadd oinstall groupadd dba groupadd oper useradd -g oinstall -G dba oracle passw ...

  6. EffectiveC#1--尽可能的使用属性(property),而不是数据成员(field)

    1.属性可以进行数据绑定 2.可以做数据安全校验.在对数据检测时,如果发现数据不满足条件,最好以抛出异常的形式来解决 如下代码不可取 public string Name { get { if(thi ...

  7. Fix an “Unapproved Caller” SecurityAgent Message in Mac OS X

    上午一进公司就被日本分公司的美女呼叫,说mac硬盘加密经常开机后需要输入硬盘加密密码才可以登录,我想应该是硬盘加密后没有给用户添加许可证,所以每次登录系统都要进行验证.于是远程到用户电脑上后,准备在硬 ...

  8. NSBundle 类

    NSBundle NSBundle继承于NSObject,NSBundle是一个程序包,其中包含了程序会使用的资源(图像,声音,编辑好的代码,nib文件). 一. 初始化NSBundle + (ins ...

  9. Eclipse 整合cvs教程及遇到的问题

    今天看着视频教程学习cvs版本管理,现在很多企业开发或许都采用了版本管理器,因为这样可以更好的进行团退开发与代码管理,所以学习一种版本管理技术还是很重要的. 最原始的独立版本管理是由两部分组成的,一个 ...

  10. Struts2中的ActionContext

    ActionContext(Action上下文) ActionContext介绍 通过上面用户注册例子的学习,我们知道Xwork与Web无关性,我们的Action不用去依赖于任何Web容器,不用和那些 ...