Quantization公式推导
作者:互联网
1.简要介绍
对于PCM量化在平稳随机中的应用具有无限振幅区间的过程,我们选择了量化步长为给定量化器大小K的最小值失真。这个概念的自然延伸是在给定K的时候,最小化关于标量量化器的所有参数的失真优化变量。参数变量为K-1个边界ui,K个映射值\(s_i^{'}\),\(0\le i \lt K\)。得到的量化器称为pdf优化标量固定长度编码的量化器。
通常,为量子化定义一个失真度量是否恰当的标准,比如量化的统计错误。我们通过选择一个恰当的边界值\(u_i\)与映射值\(s_i^{'}\)可以使得损失最小。如果我们定义失真\(D\)为\(f(\epsilon)\)的期望值,其中f是某个函数(可微),\(\epsilon\)是量化误差,输入的概率密度函数为\(p(x)\)。此时,我们定义distortion D:
\(x_{N+1}=\infty,x_1=-\infty\)
2.证明
如果我们想在N固定的情况下最小化D,我们需要D分别对\(u_i\)和\(s_i^{'}\)求偏导:
\[\begin{aligned} \frac{\partial D}{\partial u_i}=f(u_i -s_{i-1}^{'})p(x)-f(u_i-s_i^{'})p(u_i)=0 \\ i=2,...,N\ \ \ \ \ \ \ (1) \end{aligned} \]\[\begin{aligned} \frac{\partial D}{\partial s_i^{'}} = -\int_{u_i}^{u_{i+1}} f^{'}(s-s_i^{'})\ p(x)\ dx=0 \\ i=1,...,N\ \ \ \ \ \ \ (2) \end{aligned} \]\[\begin{aligned} (1)becomes (for\ p(x_i) \neq 0) \\ & f(u_i -s_{i-1}^{'})=f(u_i-s_i^{'})p(u_i) & &i=2,...,N\ \ \ \ \ \ \ (3) \end{aligned} \]\[\begin{aligned} (2)becomes \\ &&&&&&&&& \int_{u_i}^{u_{i+1}} f^{'}(s-s_i^{'})\ p(x)\ dx=0 & &i=2,...,N\ \ \ \ \ \ \ (4) \end{aligned} \]我们可以在详细的计算以下:
2.1 求\(s_i^{'}\)
\[\begin{aligned} D & = E[f(s_{in}-s_{out})] \\ & = \sum_{i=1}^{N} \int_{-u_i}^{u_{i+1}} f(s-s_i^{'})\ p(x)\ dx \\ \end{aligned} \]函数\(f(s)\)我们采用MSE。
方法一:
当等号成立时,\(E\{S\} == s_i^{'}\),即:
\[s_i^{'}=E\{S\}=\frac{\int_{u_i}^{u_{i+1}}sf(s)\ ds}{\int_{u_i}^{u_{i+1}}f(s)\ ds} \]方法二:
\[\begin{aligned} D&= E\{f(S,s_i^{'})\}=\int_{u_i}^{u_{i+1}}(s-s_i^{'})^2f(s)\ ds \\ & = \underline{\int_{u_i}^{u_{i+1}}s^2f(s)\ ds}-\underline{\int_{u_i}^{u_{i+1}}2ss_i^{'}f(s)\ ds+\int_{u_i}^{u_{i+1}}s_i^{'2}f(s)\ ds } \end{aligned} \]上述第一项为定值,所需对于D最小化来说,我们需要将第二项最小化,即:
\[Min_{s_i^{'}}\ \int_{u_i}^{u_{i+1}}s_i^{'2}f(s)\ ds-\int_{u_i}^{u_{i+1}}2s_i^{'}sf(s)\ ds \]为了方便,我们设:
\(x=\int_{u_i}^{u_{i+1}}f(s)\ ds, y=\int_{u_i}^{u_{i+1}}sf(s)\ ds\)
故:
\[\begin{aligned} & s_i^{'}=\frac{y}{x} \\ &s_i^{'}=E\{S\}=\frac{\int_{u_i}^{u_{i+1}}sf(s)\ ds}{\int_{u_i}^{u_{i+1}}f(s)\ ds} \end{aligned} \]2.2 求\(u_i\)
我们假设levels \(s_i^{'}\)已知。
\[\begin{aligned} D & = E[f(s_{in}-s_{out})] \\ & = \sum_{i=1}^{N} \int_{-u_i}^{u_{i+1}} f(s-s_i^{'})\ p(x)\ dx \\ \end{aligned} \]\[\begin{aligned} \frac{\partial D}{\partial u_i}&=\frac{\partial }{\partial u_i}\{无关项+\int_{u_i-1}^{u_{i}}(s-s_{i-1}^{'})^2f(s)\ ds+\int_{u_i}^{u_{i+1}}(s-s_i^{'})^2f(s)\ ds \} \\ = \frac{\partial }{\partial u_i}\{无关项&+\int_{u_i-1}^{u_{i}}s^2f(s)\ ds -\int_{u_i-1}^{u_{i}}2ss_{i-1}^{'}f(s)\ ds +\int_{u_i-1}^{u_{i}}s_{i-1}^{'2}f(s)\ ds \\ &+\int_{u_i}^{u_{i+1}}s^2f(s)\ ds -\int_{u_i}^{u_{i+1}}2ss_{i}^{'}f(s)\ ds +\int_{u_i}^{u_{i+1}}s_{i}^{'2}f(s)\ ds \} \\ =\frac{\partial }{\partial u_i}\{无关项&-\int_{u_i-1}^{u_{i}}2ss_{i-1}^{'}f(s)\ ds +\int_{u_i-1}^{u_{i}}s_{i-1}^{'2}f(s)\ ds \\ &-\int_{u_i}^{u_{i+1}}2ss_{i}^{'}f(s)\ ds +\int_{u_i}^{u_{i+1}}s_{i}^{'2}f(s)\ ds \} \\ =\frac{\partial }{\partial u_i}\{无关项&-\int_{u_i-1}^{u_{i+1}}2ss_{i-1}^{'}f(s)\ ds +\int_{u_i-1}^{u_{i+1}}s_{i-1}^{'2}f(s)\ ds \\ &-\int_{u_i}^{u_{i+1}}2s(s_{i}^{'}-s_{i-1}^{'})f(s)\ ds +\int_{u_i}^{u_{i+1}}(s_{i}^{'2}-s_{i-1}^{'2})f(s)\ ds \} \\ &=\frac{\partial }{\partial u_i}\{无关项-(s_{i}^{'}-s_{i-1}^{'})F_1(s)|_{u_i}^{u_{i+1}}+(s_{i}^{'2}-s_{i-1}^{'2})F_2(s)|_{u_i}^{u_{i+1}} \\ &=2(s_{i}^{'}-s_{i-1}^{'})u_if(u_i)-(s_{i}^{'2}-s_{i-1}^{'2})f(u_i) \\ &=(s_{i}^{'}-s_{i-1}^{'})f(u_i)\{2u_i-(s_{i}^{'}+s_{i-1}^{'})\}=0 \\ &==>u_i=\frac{s_{i}^{'}+s_{i-1}^{'}}{2} \end{aligned} \]完结撒花,不得不说,手敲这些公式真心累~!!!!
本文与csdncsdn同步更新。
Reference: [1]Quantizing for Minimum Distortion*
[2]Source coding
标签:partial,推导,int,公式,end,Quantization,frac,aligned,ds 来源: https://www.cnblogs.com/a-runner/p/15645202.html