Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions quantization/Readme.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
Quantization

It is a process which makes the input into discrete and maps to some limited discrete values
The method goes like this
Function Y = linear_quantation(x,B,a)
x - input
B - number of bits used to quantization levels
a - poistive real number [-a,+a) forms the range of qunatization

let's have a example and it is linear quantization
For the range [0,a): To implement this above function, divide the interval [0,1] into L = 2^(B-1)
0 = r0 < r1 < r3 .... < rL = 1 Then we compare with [a*ri, a*r(i+1) ) input at a point then
If exists then we take midpoint of above interval.
24 changes: 24 additions & 0 deletions quantization/linear_quantation.m
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
function Y = linear_quantation(x,B,a)

len = length(x) ; %% calucates the length of input
Y = zeros(1,len); %% output of quantized input-intialized here
r = linspace(0,a,B+1) ; %% creates equally spaced intervals of (B+1) in [0,a)

for v = 1:B %% it is for checking for each level
for h = 1:len %% it is for checking every input
if ( x(h)<((-a)*r(v)) && x(h)>=((-a)*r(v+1)) ) %% cheks the condition
Y(h) = ((-a)*r(v)+(-a)*r(v+1))/2 ; %% takes the mean
end
end

for h = 1:len %% it is for checking every input
if ( x(h)>=(a*r(v)) && x(h)<(a*r(v+1)) ) %% cheks the condition
Y(h) = (a*r(v)+a*r(v+1))/2 ; %% takes the mean
end
end

end



end