0% found this document useful (0 votes)
6 views

Quantization Partition

Uploaded by

Abad
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
6 views

Quantization Partition

Uploaded by

Abad
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 3

Quantization Partition:

• Suppose you are given an input signal that ranges from -5 to 5.


• Divide this range into 4 equal intervals to form a quantization partition.
• Write down the boundary values for these intervals (the partition).

Quantization Codebook:

• For each interval in your partition, assign a representative value (this value will be
used to represent all input values that fall within that interval).
• Write down your codebook (the representative values for each interval).

Quantization Partition:
divide the range [-5, 5] into 4 equal intervals.
1. Interval 1: [-5, -2.5)
2. Interval 2: [-2.5, 0)
3. Interval 3: [0, 2.5)
4. Interval 4: [2.5, 5]
Quantization Codebook:
Now, assign a representative value for each interval. Typically, this is the midpoint of the interval.
1. Interval 1: Representative value = (−5+(−2.5))/2=−3.75
2. Interval 2: Representative value = (−2.5+0)/2=−1.25
3. Interval 3: Representative value = (0+2.5)/2=1.25
4. Interval 4: Representative value =

% Define the signal range


range_min = -5;
range_max = 5;
n_intervals = 4;
% Compute interval size
interval_size = (range_max - range_min) / n_intervals;
% Initialize arrays to store partition boundaries and codebook values
partitions = zeros(1, n_intervals + 1);
codebook = zeros(1, n_intervals);
% Compute partition boundaries and codebook values
for i = 1:n_intervals
partitions(i) = range_min + (i - 1) * interval_size;
codebook(i) = range_min + (i - 0.5) * interval_size;
end
partitions(n_intervals + 1) = range_max; % Last boundary
% Display partition boundaries and codebook values
disp('Partition Boundaries:');
Partition Boundaries:

disp(partitions);
-5.0000 -2.5000 0 2.5000 5.0000

disp('Codebook Values:');
Codebook Values:

disp(codebook);
-3.7500 -1.2500 1.2500 3.7500

% Let's plot it for visualization


x = linspace(range_min, range_max, 1000); % Input signal
quantized_values = zeros(size(x));
% Quantize the input signal
for i = 1:length(x)
for j = 1:n_intervals
if x(i) >= partitions(j) && x(i) < partitions(j + 1)
quantized_values(i) = codebook(j);
break;
end
end
end
% Plot original signal vs quantized signal
figure;
plot(x, x, 'b-', 'DisplayName', 'Original Signal'); hold on;
plot(x, quantized_values, 'r--', 'DisplayName', 'Quantized Signal');
legend;
title('Quantization Example');
xlabel('Input Signal');
ylabel('Quantized Signal');
grid on;
hold off;

You might also like