栏目分类:
子分类:
返回
名师互学网用户登录
快速导航关闭
当前搜索
当前分类
子分类
实用工具
热门搜索
名师互学网 > IT > 软件开发 > 后端开发 > Python

SISO decoder for a general (n,n-1) SPC code(补充章节3)

Python 更新时间: 发布时间: IT归档 最新发布 模块sitemap 名妆网 法律咨询 聚返吧 英语巴士网 伯小乐 网商动力

SISO decoder for a general (n,n-1) SPC code(补充章节3)

前言:

           前面讲了SPC(3,2) 这里扩展一下到SPC(n,n-1)

发送的数据长度为n-1,经过SPC编码形成长度为n的

codeword.

目录

   1: 总体流程

   2:简化算法

   3: code


一 总体流程

前面知道

intrinsic LLR

    

   

主要还是在计算extrinsic LLR ,在SPC(3,2)中,以L1为例

    

    

    

 同理我们可以得到

   

   

更为通用的是:

  

证明方法: 通过数学归纳法,参考SPC(3,2),它依然是一个tanh 函数连乘 

 


二 简化算法

   2.1 符号计算

    

    

   sgn=1: 对应c=0,奇偶校验成功,保持不变

   sgn=-1:  对应c=1, 奇偶校验失败,  Flip

 2.2 大小计算

      跟SPC(3,2)一样,这里可以用一种更加简单的方法,不需要每次重新划分自己

 

   


三 code 

# -*- coding: utf-8 -*-
"""
Created on Fri Jun 10 09:23:37 2022

@author: chengxf2
"""
import numpy as np

"""
AWGN: QPSK 调制后,加入噪声,这里假设发送的都是1(0->1)
args
   std: 标准差
   mu:  均值
   n: 样本个数
"""
def sendmessage(mu=0,sigma=1.0,n=6):
    
    #np.random.seed(5)
    s = 1.0+ np.random.normal(mu, sigma, n)
    #sr = 1+std*np.random.randn(1,n)
    print("n step1 发送数据: ", s)
    return s
    


'''
获取channel LLR, intrinsic
args
   rList: 来自信道本身的LLR
   sigma: 方差
   n: 样本个数
'''
def getIntrLLR(rList, sigma,n=6):
    
    left = 2.0/sigma
    llrList = []
    for r in rList:
        llr = np.round(left*r,2)
        llrList.append(llr)
        
    print("n step2  intrinsic llr ",llrList)
    return llrList

'''
获得符号函数
arg
  llr: 似然比
return
   符号
'''
def  sign(llr):
    if llr>0:
        return 1
    else:
        return -1


'''
获得符号,hardDecsion 过程
args 
   llrList
return
    sgn: 总体的sign
    sgnList: 每个的sign
'''
def getSign(llrList):
    sgn = 1
    sgnList = []
    for llr in llrList:
        sgn_i = sign(llr)
        sgnList.append(sgn_i)
        sgn = sgn*sign(llr)
    print("n step3  get sign",sgn,"t sgnList ",sgnList)
    return sgn,sgnList

'''
找到最小值,以及位置, 找到次小值
'''
def minimum(llrList):
    
    
    #llrList.sort()
    print("n step4 minimum",llrList)
    
    n = len(llrList)
    min1 = llrList[0]
    min2 = llrList[0]
    minpos = 0
   
    
    for i in range(1,n):
        llr = llrList[i]
        if llr 

   

 

 

# -*- coding: utf-8 -*-
"""
Created on Fri Jun 10 08:44:34 2022

@author: chengxf2
"""
#-*-coding:utf-8-*-
"""
python绘制标准正态分布曲线
"""
# ==============================================================
import numpy as np
import math
import matplotlib.pyplot as plt


def gd(x, mu=0, sigma=1.0):
  """生成数据

  Argument:
    x: array
      输入数据(自变量)
    mu: float
      均值
    sigma: float
    方差
  """
  
  left = 1 / (np.sqrt(2 * math.pi) * np.sqrt(sigma))
  right = np.exp(-(x - mu)**2 / (2 * sigma))
  return left * right


if __name__ == '__main__':
  # 自变量
  x = np.arange(-4, 5, 0.1)
  # 因变量(不同均值或方差)
  y_1 = gd(x, 0, 2.0)
  y_2 = gd(x, 0, 1.0)
  y_3 = gd(x, 0, 5.0)
  y_4 = gd(x, 0, 0.2)

  # 绘图
  plt.plot(x, y_1, color='green')
  plt.plot(x, y_2, color='blue')
  plt.plot(x, y_3, color='yellow')
  plt.plot(x, y_4, color='red')
  # 设置坐标系
  plt.xlim(-5.0, 5.0)
  plt.ylim(-0.2, 1)
  #由于axes会获取到四个轴,而我们只需要两个轴,所以我们需要把另外两个轴隐藏,把顶部和右边轴的颜色设置为none,将不会显示
  ax = plt.gca()
  ax.spines['right'].set_color('none')
  ax.spines['top'].set_color('none')
  ax.xaxis.set_ticks_position('bottom')
  ax.spines['bottom'].set_position(('data', 0))
  ax.yaxis.set_ticks_position('left')
  ax.spines['left'].set_position(('data', 0))

  plt.legend(labels=['$mu = 0, sigma^2=2.0$', '$mu = 0, sigma^2=1.0$', '$mu = 0, sigma^2=5.0$', '$mu = 0, sigma^2=0.2$'])
  plt.show()

转载请注明:文章转载自 www.mshxw.com
本文地址:https://www.mshxw.com/it/960579.html
我们一直用心在做
关于我们 文章归档 网站地图 联系我们

版权所有 (c)2021-2022 MSHXW.COM

ICP备案号:晋ICP备2021003244-6号