您使用的量化公式会将输入值映射到量化版本。但是,它不会将结果限制为仅 512 个级别,因为您的输入信号可能超出[-1,+1]
范围,并且您没有做任何事情来限制量化器输出(或输入)。
要限制您可以使用的值min
和max
内置函数。但是,由于它们使用复数的模数,因此您必须首先将数字分成实部和虚部。因此,量化具有实部和虚部的复数,每个都限制在范围内,[minValue,maxValue]
可以通过以下方式完成:
q = (maxValue-minValue)/(2^9-1);
realPart = min(max(real(s),minValue),maxValue);
realPart = minValue + round((realPart-minValue)/q)*q;
imagPart = min(max(imag(s),minValue),maxValue);
imagPart = minValue + round((imagPart-minValue)/q)*q;
quantSignal = realPart + j*imagPart;
我之前提到过,具有单位方差的正常信号通常不会限制在[-1,1]
范围内(或任何范围内)。因此,通常尝试最小化量化误差的度量,例如均方误差(未量化输入和相应量化输出之间的平方差的期望值)。
For a uniform quantizer and given specific signal characteristics (in this case a complex Gaussian signal) this mean squared error is a function of the number of quantization levels and the quantizer's input range. For 512 levels, the real and imaginary parts should ideally be within approximately +/- 4.2 standard deviations. Since your standard deviation is sqrt(0.5)
for the real and imaginary parts, this can be achieved with
maxValue = 4.2*sqrt(0.5);
minValue = -maxValue;
Should you need the real and imaginary part of your quantized output to be constrained to a specific range, then you may apply a scaling factor at the output of the quantizer (e.g. divide by 4.2*sqrt(0.5)
to get the real and imaginary part constrained to [-1,+1]
).