首页 > 其他分享 >5.3 Optimal Codes

5.3 Optimal Codes

时间:2023-10-15 09:44:05浏览次数:35  
标签:5.3 frac log sum Codes Optimal Rightarrow partial lambda

From Section 5.2, we know that any prefix code satisfies Kraft inequality.

Our goal is to design prefix codes with minimum \(L(C)\), by Kraft inequality, such goal is equivalent to finding \(l_1, l_2, ..., l_m\) satisfying Kraft inequality and \(L(C)=\sum_{i=1}^m p_i l_i\) is less than the \(L\) of any other prefix codes.

Let's formalize this problem mathematically:

Minimize $L=\sum_{i=1}^m p_i l_i $ such that $\sum_{i=1}^m D^{-l_i} \leq 1 $ and $ l_1,...,l_m $ are integers

This is a constrained optimization problem, and we can use Lagrange multipliers to solve it:

\[J=\sum_{i=1}^m p_i l_i +\lambda (\sum_{i=1}^m D^{-l_i}) \]

Differentiating w.r.t. \(l_i\) and \(\lambda\), we have:

\[\frac{\partial J}{\partial \lambda}=0 \Rightarrow \sum_{i=1}^m D^{-l_i}=1 \]

\[\frac{\partial J}{\partial l_i}=0 (i=1,2,...,m) \Rightarrow \\ p_i -\lambda D^{-l_i} \log_e D =0 \Rightarrow \\ D^{-l_i} = \frac{p_i}{\lambda \log_e D} \Rightarrow \\ \sum_{i=1}^mD^{-l_i} = \frac{\sum_{i=1}^m p_i}{\lambda \log_e D} \Rightarrow \\ \lambda = \frac{1}{\log_e D} \]

Substituting \(\lambda = \frac{1}{\log_e D}\) into $D^{-l_i} = \frac{p_i}{\lambda \log_e D} $:

\[D^{-l_i}=p_i \Rightarrow l_i^* = -\log_D p_i \]

where \(l_i^*\) is the optimal solution to such problem, but here we didn't consider the condition of integers. So these non-integer codeword lengths yields:

\[L^* =\sum_{i=1}^m p_i l_i^* = -\sum_{i=1}^m p_i \log_D p_i =H_{D}(X)=H_2(X)/\log_2 D \]

Intuitively, we should choose \(l_i\) close to \(l_i^*\). Now, we verify optimality directly in the proof of the following theorem:

Thm. 5.3.1 The expected length \(L\) of any prefix D-ary code for a random variable \(X\) is greater than or equal to the entropy \(H_D(X)\); that is,

\[L\geq H_D(X) \]

with equality iff \(D^{-l_i}=p_i\) --- such dist. is called D-adic.

Proof:

\[L-H_D(X)=\sum_i p_il_i +\sum_i \log_D p_i \\ =-\sum_i p_i \log_D D^{-li}+\sum_i \log_D p_i \\ =-\sum_i p_i \log_D \frac{p_i}{D^{-li}}\times\frac{\sum_j D^{-l_j}}{\sum_j D^{-l_j}} \]

Let \(r_i=\frac{D^{-l_i}}{\sum_j D^{-l_j}}\), obviously, \(r_i\) is a pmf, as \(\sum r_i=1\) and \(r_i\in [0,1]\).

And let \(c=\sum_j D^{-l_j}\), \(c\leq 1\) by Kraft inequality. Then,

\[= \sum_i p_i\log_D \frac{p_i}{r_i}+\sum_i p_i \log_D \frac{1}{c}\\ = D(\mathbf{p}||\mathbf{r})+\log_D\frac{1}{c} \geq 0 \]

first term is the relative entropy/KL divergence between distributions \(\mathbf{p}\) and \(\mathbf{r}\), which is always non-negative, and the second term is still non-negative because \(\frac{1}{c} \geq 1\).

标签:5.3,frac,log,sum,Codes,Optimal,Rightarrow,partial,lambda
From: https://www.cnblogs.com/setdong/p/17765269.html

相关文章

  • tiup离线安装tidb6.5.3
    tidb6.5.3规划ip资源规划备注192.168.10.574C/8G/100Gpd、tikv192.168.10.564C/8G/100Gtikv、pd、cdc192.168.10.554C/8G/100Gtidb、tikv192.168.10.544C/8G/100Gpd、tidb192.168.10.534C/8G/100G监控、中控、tidb软件安装1、配置......
  • ARM+Codesys标准通用型控制器
    整机工业级设计,通讯外设经过隔离保护 电源宽电压设计(9~36VDC)丰富的通讯接口,满足多种场合控制和通讯需求 四核工业级处理器,高性能,低功耗,高可靠性    机身无风扇设计,外壳小巧搭载内核100%自主化大型实时操作系统SylixOS,支持   POSIX 接口规范;拥有完全自主可控的知识......
  • 痞子衡嵌入式:MCUBootUtility v5.3发布,利用XMCD轻松使能外部RAM
    --痞子衡维护的NXP-MCUBootUtility工具距离上一个大版本(v5.0.0)发布过去4个多月了,期间痞子衡也做过三个小版本更新,但不足以单独介绍。这一次痞子衡为大家带来了全新重要版本v5.3.x,这次更新主要是想和大家特别聊聊XMCD这个特性的支持。一、v5.1-v5.3更新记录--v5.1.......
  • Packet Tracer V5.2-5.3官方正式版下载
    《思科路由器交换机模拟软件》(Ciscopackettracer)官方5.2-5.3版+[压缩包]下载地址:http://www.verycd.com/topics/2823603/1、模拟器实际设备的硬件!这个对于网络技术学习者而言可是跟玩真机一样,设备模块、面板显示跟真机一样!安装模块还需要Poweroff!我想这个功能对于那些还没有见......
  • 源码编译Unreal Engine升级到5.3
    1.更新代码gitfetchorigin2.检出5.3.0releasegitcheckout5.3.0release3.安装依赖Setup.bat4.生成项目文件GenerateProjectFiles.bat5.打开UE5.sln编译配置:"DevelopmentEditor","Win64"......
  • 基于CODESYS的数据跟踪
    概述CODESYS上位机编程软件支持Trace,也就是变量跟踪功能,用波形记录某个变量,在联机调试时可以使用波形来协助用户分析程序逻辑,帮助用户分析设备运行状态。下图中的Trace跟踪了4个变量,波形的横轴为时间,纵轴为变量值。基本配置鼠标右击设备的“Application”节点,弹出如下图所示的......
  • android中的VERSION和VERSION_CODES和compileSdkVersion, minSdkVersion 和 targetSdk
    一背景经常会有代码中用到  Build.VERSION.SDK_INT<Build.VERSION_CODES.O,这是指什么意思。在app项目中,经常会看到android{compileSdkVersion30buildToolsVersion"30.0.3"defaultConfig{applicationId"com.yl.qrcode"minSdkVersio......
  • 【云原生持续交付和自动化测试】5.3 持续交付和DevOps实践基础知识
     【云原生持续交付和自动化测试】5.3持续交付和DevOps实践基础知识5.3.1什么是持续交付云原生下对持续交付(ContinuousDelivery)是一种软件开发方法,旨在实现高质量、可靠且可持续的软件交付。它强调通过自动化的流程和工具链,使得软件的构建、测试和部署过程可以频繁地进行,......
  • 15.3K Star,超好用的开源协作式数字白板:tldraw
    大家好,我是TJ今天给大家推荐一个开源协作式数字白板:tldraw。tldraw的编辑器、用户界面和其他底层库都是开源的,你可以在它的开源仓库中找到它们。它们也在NPM上分发,提供开发者使用。您可以使用tlDraw为您的产品创建一个临时白板,或者将其作为构建自己应用的工具来使用。在线体验......
  • 电气工程师必学------CODESYS v3.5 入门学习笔记(一)
    一、新建工程打开软件新建工程,如图此教程只是入门练习,所以这里一般情况下都是创建的Standardproject,也就是标准工程。窗口下方可以设置工程名称与存放位置。紧接着是选择设备与编译语言。初学者条件有限就直接上仿真,电脑是windowsx64的话设备选择上图所示就OK。语言这里我......