# 0.12 Lab 8 - number representation and quantization  (Page 5/5)

 Page 5 / 5
$PSNR=\frac{{P}_{Y}}{{P}_{E}}$

In this expression, the noise is the error signal E . Generally, this means that a higher PSNR implies a less noisy signal.

From previous labs we know the power of a sampled signal, $x\left(n\right)$ , is defined by

${P}_{x}=\frac{1}{L}\sum _{n=1}^{L}{x}^{2}\left(n\right)$

where $L$ is the length of $x\left(n\right)$ . Compute the PSNR for the four quantized speech signals from the previoussection.

In evaluating quantization (or compression) algorithms, a graph called a “rate-distortion curve" is often used.This curve plots signal distortion vs. bit rate . Here, we can measure the distortion by $\frac{1}{PSNR}$ , and determine the bit rate from the number of quantization levels and sampling rate.For example, if the sampling rate is 8000 samples/sec, and we are using 7 bits/sample, the bit rate is 56 kilobits/sec (kbps).

Assuming that the speech is sampled at 8kHz, plot the rate distortion curve using $\frac{1}{PSNR}$ as the measure of distortion.Generate this curve by computing the PSNR for 7, 6, 5,..., 1 bits/sample. Make sure the axes of the graphare in terms of distortion and bit rate .

Hand in a list of the 4 PSNR values, and the rate-distortion curve.

## Max quantizer

In this section, we will investigate a different type of quantizer which produces less noise for a fixed number of quantization levels.As an example, let's assume the input range for our signal is [-1,1], but most of the input signal takes on values between [-0.2, 0.2]. If we place more of the quantizationlevels closer to zero, we can lower the average error due to quantization.

A common measure of quantization error is mean squared error (noise power). The Max quantizer is designed to minimize the mean squared error for a given set of training data.We will study how the Max quantizer works, and compare its performance to that of the uniform quantizer which was used in the previoussections.

## Derivation

The Max quantizer determines quantization levels based on a data set's probability density function, $f\left(x\right)$ , and the number of desired levels, $N$ . It minimizes the mean squared error between the originaland quantized signals:

$\epsilon =\sum _{k=1}^{N}{\int }_{{x}_{k}}^{{x}_{k+1}}{\left({q}_{k}-x\right)}^{2}f\left(x\right)dx$

where ${q}_{k}$ is the ${k}^{th}$ quantization level, and ${x}_{k}$ is the lower boundary for ${q}_{k}$ . The error $\epsilon$ depends on both ${q}_{k}$ and ${x}_{k}$ . (Note that for the Gaussian distribution, ${x}_{1}=-\infty$ , and ${x}_{N+1}=\infty$ .) To minimize $\epsilon$ with respect to ${q}_{k}$ , we must take $\frac{\partial \epsilon }{\partial {q}_{k}}=0$ and solve for ${q}_{k}$ :

${q}_{k}=\frac{{\int }_{{x}_{k}}^{{x}_{k+1}}xf\left(x\right)dx}{{\int }_{{x}_{k}}^{{x}_{k+1}}f\left(x\right)dx}$

We still need the quantization boundaries, ${x}_{k}$ . Solving $\frac{\partial \epsilon }{\partial {x}_{k}}=0$ yields:

${x}_{k}=\frac{{q}_{k-1}+{q}_{k}}{2}$

This means that each non-infinite boundary is exactly halfway in between the two adjacent quantization levels, and that eachquantization level is at the centroid of its region. [link] shows a five-level quantizer for a Gaussian distributed signal. Note that the levels are closer together in areas of higher probability.

## Implementation, error analysis and comparison

In this section we will use Matlab to compute an optimal quantizer, and compare its performance to the uniform quantizer.Since we almost never know the actual probability density function of the data that the quantizer will be applied to,we cannot use equation [link] to compute the optimal quantization levels.Therefore, a numerical optimization procedure is used on a training set of data to compute the quantization levels and boundaries which yield the smallest possible error for that set.

Matlab has a built-in function called lloyds which performs this optimization.It's syntax is...

[partition, codebook] = lloyds(training_set, initial_codebook);

This function requires two inputs. The first is the training data set, from which it will estimatethe probability density function. The second is a vector containing an initial guess of theoptimal quantization levels. It returns the computed optimalboundaries (the “partition”) and quantization levels (the “codebook”).

Since this algorithm minimizes the error with respect to the quantization levels, it is necessary to provide a decent initial guess of the codebook to help ensure a valid result. If the initial codebook is significantly “far" away from the optimalsolution, it's possible that the optimization will get trapped in a local minimum, and the resultant codebook may perform quite poorly.In order to make a good guess, we may first estimate the shape of the probability density function of the training set usinga histogram. The idea is to divide the histogram into equal “areas" and choosequantization levels as the centers of each of these segments.

First plot a 40-bin histogram of this speech signal using hist(speech,40) , and make an initial guess of the four optimal quantization levels.Print out the histogram. Then use the lloyds function to compute an optimal 4-level codebook using speech.au as the training set.

Once the optimal codebook is obtained, use the codebook and partition vectors to quantize the speech signal. This may be done with a for loop and if statements. Then compute the error signal and PSNR.On the histogram plot, mark where the optimal quantization levels fall along the x-axis.

## Inlab report

1. Turn in the histogram plot with the codebook superimposed.
2. Compare the PSNR and sound quality of the uniform- and Max-quantized signals.
3. If the speech signal was uniformly distributed, would the two quantizers be the same? Explain your answer.

how to know photocatalytic properties of tio2 nanoparticles...what to do now
it is a goid question and i want to know the answer as well
Maciej
Do somebody tell me a best nano engineering book for beginners?
what is fullerene does it is used to make bukky balls
are you nano engineer ?
s.
fullerene is a bucky ball aka Carbon 60 molecule. It was name by the architect Fuller. He design the geodesic dome. it resembles a soccer ball.
Tarell
what is the actual application of fullerenes nowadays?
Damian
That is a great question Damian. best way to answer that question is to Google it. there are hundreds of applications for buck minister fullerenes, from medical to aerospace. you can also find plenty of research papers that will give you great detail on the potential applications of fullerenes.
Tarell
what is the Synthesis, properties,and applications of carbon nano chemistry
Mostly, they use nano carbon for electronics and for materials to be strengthened.
Virgil
is Bucky paper clear?
CYNTHIA
so some one know about replacing silicon atom with phosphorous in semiconductors device?
Yeah, it is a pain to say the least. You basically have to heat the substarte up to around 1000 degrees celcius then pass phosphene gas over top of it, which is explosive and toxic by the way, under very low pressure.
Harper
Do you know which machine is used to that process?
s.
how to fabricate graphene ink ?
for screen printed electrodes ?
SUYASH
What is lattice structure?
of graphene you mean?
Ebrahim
or in general
Ebrahim
in general
s.
Graphene has a hexagonal structure
tahir
On having this app for quite a bit time, Haven't realised there's a chat room in it.
Cied
what is biological synthesis of nanoparticles
what's the easiest and fastest way to the synthesize AgNP?
China
Cied
types of nano material
I start with an easy one. carbon nanotubes woven into a long filament like a string
Porter
many many of nanotubes
Porter
what is the k.e before it land
Yasmin
what is the function of carbon nanotubes?
Cesar
I'm interested in nanotube
Uday
what is nanomaterials​ and their applications of sensors.
what is nano technology
what is system testing?
preparation of nanomaterial
Yes, Nanotechnology has a very fast field of applications and their is always something new to do with it...
what is system testing
what is the application of nanotechnology?
Stotaw
In this morden time nanotechnology used in many field . 1-Electronics-manufacturad IC ,RAM,MRAM,solar panel etc 2-Helth and Medical-Nanomedicine,Drug Dilivery for cancer treatment etc 3- Atomobile -MEMS, Coating on car etc. and may other field for details you can check at Google
Azam
anybody can imagine what will be happen after 100 years from now in nano tech world
Prasenjit
after 100 year this will be not nanotechnology maybe this technology name will be change . maybe aftet 100 year . we work on electron lable practically about its properties and behaviour by the different instruments
Azam
name doesn't matter , whatever it will be change... I'm taking about effect on circumstances of the microscopic world
Prasenjit
how hard could it be to apply nanotechnology against viral infections such HIV or Ebola?
Damian
silver nanoparticles could handle the job?
Damian
not now but maybe in future only AgNP maybe any other nanomaterials
Azam
Hello
Uday
I'm interested in Nanotube
Uday
this technology will not going on for the long time , so I'm thinking about femtotechnology 10^-15
Prasenjit
can nanotechnology change the direction of the face of the world
how did you get the value of 2000N.What calculations are needed to arrive at it
Privacy Information Security Software Version 1.1a
Good
Got questions? Join the online conversation and get instant answers!