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. JAX-WS 可运行项目

    该项目是通过JAX-WS实现的WebService服务,其中包括了1.关于最简单的WebService服务的创建2.关于文件交互的WebService的创建 代码中包括了服务端代码和客户端代码(客户端 ...

  2. WebFrom模拟MVC

    如:  aspx前台     这样写生成页面时不会产生新的html标签,用控件则会产生新的html标签 <h1><%= title %></h1> <p> ...

  3. [转]CodeIgniter与Zend Acl结合实现轻量级权限控制

    Tag :CodeIgniter  Zend Acl 权限控制 1. Zend_Acl简介 Zend_Acl 为权限管理提供轻量并灵活的访问控制列表 (ACL,access control list) ...

  4. 设计一个算法,求非空二叉树中指定的第k层(k&gt;1)的叶子节点的个数

    思想:採用基于层序遍历的方法. 用level扫描各层节点,若某一层的节点出队后.rear指向该层中最右节点.则将rear赋值给last(对于第一层.last=1).在出队时,若front=last,表 ...

  5. 划分树 poj2104 hdu5249

    KPI Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others) Total Submis ...

  6. 初识_IOS-简易计算器-问题总结

    作为一个新手,只好拿所有开发者都写的不想写又没有太大难度的计算器来下手咯.比较细一点,耐心哟. 我们都知道,计算器首要任务就是计算,那我们就直接看成A+B=C,来进行分析了.对A,B,C三个对象进行分 ...

  7. 前端--关于CSS文本

    文本是网页中最重要的一种内容形式,文本几乎可以写在任何地方,块级元素中可以写行内元素中也可以写.文本都是由一个个字符组成的 ,在css布局中,每一个字符都有一个em框,通常font-size设置的大小 ...

  8. HTML - Textarea - 空格的问题解决方式

    第一种方式: <textarea name="textareaname" rows="XX" cols="XX" ></t ...

  9. ArcEngine 添加字段

    private void AddField(IFeatureClass pFeatureClass, string name, string aliasName, esriFieldType Fiel ...

  10. html5 拖放---(二)转

    draggable是一个枚举属性,用于指定一个标签是否可以被拖拽.有以下四种取值: true 表示此元素可拖拽 false 表示此元素不可拖拽 auto 除img和带href的标签a标签表示可拖拽外, ...