diff --git a/quantization/Readme.md b/quantization/Readme.md new file mode 100644 index 0000000..5112fbc --- /dev/null +++ b/quantization/Readme.md @@ -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. \ No newline at end of file diff --git a/quantization/linear_quantation.m b/quantization/linear_quantation.m new file mode 100644 index 0000000..69b711c --- /dev/null +++ b/quantization/linear_quantation.m @@ -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 \ No newline at end of file