# fixed.realQuantizationNoiseStandardDeviation

Estimate standard deviation of quantization noise of real-valued signal

## Syntax

``noiseStandardDeviation = fixed.realQuantizationNoiseStandardDeviation(precisionBits)``

## Description

example

````noiseStandardDeviation = fixed.realQuantizationNoiseStandardDeviation(precisionBits)` returns an estimate of the quantization noise standard deviation of a real-valued signal with a quantization level q=2-precisionBits, where `precisionBits` is the required number of bits of precision.```

## Examples

collapse all

Quantizing a real signal to $p$ bits of precision can be modeled as a linear system that adds normally distributed noise with a standard deviation of ${ϛ}_{\text{noise}}=\frac{{2}^{-p}}{\sqrt{12}}$ [1,2].

Compute the theoretical quantization noise standard deviation with $p$ bits of precision using the `fixed.realQuantizationNoiseStandardDeviation` function.

```p = 14; theoreticalQuantizationNoiseStandardDeviation = fixed.realQuantizationNoiseStandardDeviation(p);```

The returned value is ${ϛ}_{\text{noise}}=\frac{{2}^{-p}}{\sqrt{12}}$.

Create a real signal with $n$ samples.

```rng('default'); n = 1e6; x = rand(1,n);```

Quantize the signal with $p$ bits of precision.

```wordLength = 16; x_quantized = quantizenumeric(x,1,wordLength,p);```

Compute the quantization noise by taking the difference between the quantized signal and the original signal.

`quantizationNoise = x_quantized - x;`

Compute the measured quantization noise standard deviation.

`measuredQuantizationNoiseStandardDeviation = std(quantizationNoise)`
```measuredQuantizationNoiseStandardDeviation = 1.7607e-05 ```

Compare the actual quantization noise standard deviation to the theoretical and see that they are close for large values of $n$.

`theoreticalQuantizationNoiseStandardDeviation`
```theoreticalQuantizationNoiseStandardDeviation = 1.7619e-05 ```

References

1. Bernard Widrow. “A Study of Rough Amplitude Quantization by Means of Nyquist Sampling Theory”. In: IRE Transactions on Circuit Theory 3.4 (Dec. 1956), pp. 266–276.

2. Bernard Widrow and István Kollár. Quantization Noise – Roundoff Error in Digital Computation, Signal Processing, Control, and Communications. Cambridge, UK: Cambridge University Press, 2008.

## Input Arguments

collapse all

Required number of bits of precision, specified as a positive integer-valued scalar.

Data Types: `double`

## Output Arguments

collapse all

Noise standard deviation, returned as a scalar.

## Tips

`fixed.realQuantizationNoiseStandardDeviation` is used in these functions.

## Algorithms

The variance of a real-valued error sequence e(k) with quantization level q=2-precisionBits [1][2] is

`${\sigma }_{q}^{2}=\frac{1}{q}{\int }_{-q/2}^{q/2}{e}^{2}de=\frac{{q}^{2}}{12}=\frac{{2}^{-2precisionBits}}{12}.$`

The standard deviation of a real error sequence e(k) is

`${\sigma }_{q}=\frac{{2}^{-precisionBits}}{\sqrt{12}}.$`

## References

[1] Widrow, Bernard. "A Study of Rough Amplitude Quantization by Means of Nyquist Sampling Theory." IRE Transactions on Circuit Theory 3, no.4 (December 1956): 266-276.

[2] Widrow, Bernard, and Kollár, István. Quantization Noise – Roundoff Error in Digital Computation, Signal Processing, Control, and Communications. Cambridge, UK: Cambridge University Press, 2008.

## Version History

Introduced in R2021b