Problems AT sin(t / T ) is sampled at t s /( 2 ) samples/second. Find the Fourier transform of the sampled signal. Find the output of the Problem 1. Assume that the bandlimited signal x(t ) ideal low-pass filter with cut-off frequency s / 2 . Compare the output of the ideal low-pass filter with the original signal x(t ) ( s 2 / T , / T s 2 / T ). Solution AT sin( t / T ) jt 2 AT sin( t / T ) AT sin( / T ) sin( / T ) X ( ) e dt cos tdt dt t 0 t 0 t t AT , / T . 0 , / T (We take into account that each of the integrals is equal to / 2 depending on the sign of ( / T ) ). If S 2 / T x(t ) 1 2 /T ATe jt d /T AT /T cos td 0 AT sin t t T . If / T S 2 / T 1 x(t ) 2 s / T /2 s 1 AT ATe d 2 2 AT cos td 2 s / T s / T jt s / T 0 cos td 2 s / 2 AT cos td s / T AT sin( s )t T 2 AT sin / 2t sin t s s t t T Problem 2. Quantize the given sequence x =(2.3, 1.78, 1.40, 0.10, 0.75, 0.65, 0.44, 0.58, 0.53, 0.05, 0.76, 0.63, 1.89, 0.48, 0.80, 0.40, 0.71, 0.93, 0.16, 2.4) by fixed-rate uniform scalar quantizer with rate 3, 2, and 1 bit/sample. Compute the average quantization error. Estimate entropy of the output sequence. (The minimal value is –3, the maximal value +3). Compare with performance of variable-rate uniform quantizer with the step size equal to 0.6. Solution. If R 3 then M 8 and we obtain the following sequence of thresholds: 3, 2.25, 1.5, 0.75, 0, 0.75, 1.5, 2.25, 3. The approximating values are: 2.625, 1.875, 1.125, 0.375, 0.375, 1.125, 1.875, 2.625. The quantized sequence looks like: 0, 1, 5, 3, 5, 4, 4, 3, 3, 4, 2, 3, 6, 4, 2, 4, 3, 2, 4, 7 or in binary form : 000001101011101100100011011100010011110100010100011010100111. Number of bits =60. The reconstructed sequence is 2.625, 1.875, 1.125, 0.375, 1.125, 0.375, 0.375, 0.375, 0.375, 0.375, 1.125, 0.375, 1.875, 0.375, 1.125, 0.375, 0.375, 1.125, 0.375, 2.625. The total quantization error is equal to (2.3 2.625) 2 (1.78 1.875) 2 (1.4 1.125) 2 (0.1 0.375) 2 (0.75 1.125) 2 (0.65 0.375) 2 (0.44 0.375) 2 (0.58 0.375) 2 (0.53 0.375) 2 (0.05 0.375) 2 (0.76 1.125) 2 (0.63 0.375) 2 (1.89 1.875) 2 (0.48 0.375) 2 (0.80 1.125) 2 (0.40 0.375) 2 (0.71 0.375) 2 (0.93 1.125) 2 (0.16 0.375) 2 (2.4 2.625) 2 1.22 The average quantization error is 1.22/20=0.061. The signal energy is E xi2 24.95 The relative error is r / E 1.22 / 24.95 0.049. Estimates of probabilities are: p0 1 / 20 , p1 1 / 20, p2 3 / 20, p3 5 / 20, p4 6 / 20, p5 2 / 20, p6 1 / 20, p7 1 / 20 . The estimate of the entropy is H pi log 2 pi 2.6 bits. i Number of bits = 52. If R 2 then M 4 and the thresholds are: 3, 1.5, 0, 1.5, 3. The approximating values are: 2.25, 0.75, 0.75, 2.25. The quantized sequence looks like 0,0,2,1,2,2,2,1,1,2,1,1,3,2,1,2,1,1,2,3 or in binary form 0000100110101001011001011110011001011011. Number of bits=40. The reconstructed sequence is 2.25, 2.25, 0.75, 0.75, 0.75, 0.75, 0.75, 0.75, 0.75, 0.75, 0.75, 0.75, 2.25, 0.75, 0.75, 0.75, 0.75, 0.75, 0.75, 2.25. The total error is: (2.3 2.25) 2 (1.78 2.25) 2 (1.4 0.75 2 (0.1 0.75) 2 (0.75 0.75) 2 (0.65 0.75) 2 (0.44 0.75) 2 (0.58 0.75) 2 (0.53 0.75) 2 (0.05 0.75) 2 (0.76 0.75) 2 (0.63 0.75) 2 (1.89 2.25) 2 (0.48 0.75) 2 (0.80 0.75) 2 (0.40 0.75) 2 (0.71 0.75) 2 (0.93 0.75) 2 (0.16 0.75) 2 (2.4 2.25) 2 2.49. The average error is 2.49/20=0.1245. The relative error is 2.49/24.95=0.10. Estimates of symbol probabilities are: p0 2 / 20, p1 8 / 20, p2 8 / 20, p3 2 / 20. The estimate of the entropy is H 1.72 bits. Number of bits= 35. Compare the fixed-rate quantizer with a variable-length quantizer. Let quantization step 0.6. The quantized sequence can be obtained as q round (x / ) . We obtain 4, 3, 2, 0, 1, 1, 1, 1, 1, 0, 1, 1, 3, 1, 1, 1, 1, 2, 0, 4. The reconstructed sequence has the form 2.4, 1.8, 1.2, 0, 0.6, 0.6, 0.6, 0.6, 0.6, 0, 0.6, 0.6, 1.8, 0.6, 0.6, 0.6, 0.6, 1.2, 0, 2.4 Estimates of probabilities are: p4 1 / 20, p 3 1 / 20, p2 1 / 20, p1 6 / 20, p0 3 / 20, p1 5 / 20, p2 1/ 20, p3 1 / 20, p4 1/ 20. The estimate of the entropy is H 2.72 bits. Number of bits =54. The total error is: 0.3584 , the average error 0.3584/20=0.018. The relative error r 0.0144. Problem 3. Assume that X is the Gaussian variable with zero average value and variance equal to 1. For fixed-rate quantizer with M 4 and given sets of thresholds and approximating values compute probabilities of approximating values. Estimate entropy of the discrete source formed by the quantizer outputs. Estimate the MSE. The sets of thresholds ti and approximating values yi are: - t0 , t1 1.5, t2 0, t3 1.5, t4 , y0 2.25, y1 0.75, y2 0.75, y3 2.25 , - t0 , t1 1.0, t2 0, t3 1.0 , t4 , y0 1.5, y1 0.5, y2 0.5, y3 1.5 , - t0 , t1 2.0, t2 0, t3 2.0 , t4 , y0 3.0, y1 1.0, y2 1.0, y3 3.0 Solution. 1.5 p0 0 p1 1.5 (See qfun.m , erf ( x) x2 1 2 e dx Q(1.5) 0.07 . 2 x2 x2 1 2 1 2 e dx e dx 0.5 1 0.5 2 2 1.5 2 x e 0 t 2 2 1.5 x2 1 2 e dx 0.43 . 2 x dt , Q( x) 0.5 0.5erf .) 2 p2 0.43 , p3 0.07 , H p0 log 2 p0 p1 log 2 p1 p2 log 2 p2 p3 log 2 p3 1.58 bits. 0 x 1.5 1 x 1 ( x yi ) dx 2 e 2 ( x 2.25) 2 dx e 2 ( x 0.75) 2 dx . i 1 t i 1 1.5 2 2 In order to compute the quantization error first consider the following auxiliary integrals : b x2 b2 / 2 a2 b2 1 1 1 2 t 2 e xdx e dt e e 2 . 2 a 2 a2 / 2 2 4 ti 1 e 2 x2 2 2 2 2 b 1 e 2 a x2 2 x 2 dx 2 b/ 2 e a/ 2 t 2 2 t dt 2 1 2 ( du tet dt , u e t , v t, dv dt. ) 2 b/ 2 2 2 1 t 2 b / 2 1 e t e t dt . 2 a/ 2 2 a/ 2 In general case for M 4 : 2 1 t 2 t / 2 1 t12 / 2 2 Q( t1 ) 2 y1 e y12Q(t1 ) e 1 2 2 2 2 1 t 2 0 2 1 2 (0.5 Q(t1 )) 2 y2 et1 / 2 1 y22 0.5 Q(t1 ) . e t 2 2 t1 / 2 2 Inserting our input data we obtain 2 1 t 2 1.5 / 2 1 2.25 / 2 e t Q( 1.5) 2 2.25 e (2.25)2 Q(1.5) 2 2 2 2 2 1 t 2 0 1 e t 2 (0.5 Q(1.5)) 2 0.75 e 2.25 / 2 1 (0.75) 2 0.5 Q(1.5) . 2 1.5 / 2 2 2 0.1898 Let t1 1.0, t3 1.0 and y0 1.5, y1 0.5, y2 0.5, y3 1.5 . 1.0 p0 x2 0 x2 1 2 e dx Q(1.0) 0.16. 2 x2 1 2 1 2 p1 e dx e dx 0.5 1 0.5 1.0 2 1.0 2 H=1.90 bits, 0.1189. 1.0 x2 1 2 e dx 0.34. 2 Let t1 2.0, t3 2.0 and y0 3.0, y1 1.0, y2 1.0, y3 3.0 2.0 p0 0 x2 1 2 e dx Q(1.0) 0.02. 2 x2 x2 2.0 x2 1 2 1 2 1 2 p1 e dx e dx 0.5 1 0.5 e dx 0.48 2 2 2 2.0 2.0 H=1.27 bits, 0.33 . When the quantization error reduces the distribution of approximating values becomes more uniform (probabilities are closer to each other) and hence the entropy increases. Problem 4. For random Gaussian variable from problem 3 find thresholds and approximating values for the nonuniform optimal quantizer with M 4. Since t0 , t2 0, t3 t1, t4 we should choose only t1 . Solution Let t1 . Set p 0. Let the optimization accuracy be 0.0001. The approximating values are: 1 2 y1 1 2 t1 xe t1 e x2 2 x2 2 dx dx t2 1 2 e , y2 Q (t1 ) 2 1 2 0 xe x2 2 dx t1 0 1 e 2 t1 x2 2 dx t12 2 (e 1) . (0.5 Q(t1 )) 2 2 1 t 2 t / 2 1 t12 / 2 e 1 Q(t1 ) 2 y1 e ( y1 ) 2 Q(t1 ) 2 2 2 2 2 1 t 2 0 2 1 e t 2 (0.5 Q(t1 )) 2 y2 e t1 / 2 1 ( y2 ) 2 0.5 Q(t1 ) . 2 t1 / 2 2 2 Compute the error by the formula 2 1 t 2 t / 2 1 t12 / 2 e 1 2 Q(t1 ) 2 y1 e ( y1 )2 Q(t1 ) . 2 2 2 2 1 t 2 0 2 1 e t 2 (0.5 Q(t1 )) 2 y2 e t1 / 2 1 ( y2 ) 2 0.5 Q(t1 ) . 2 t1 / 2 2 2 y y2 . Return to computing approximating values. If p . Set p . Compute t1 1 2 Otherwise stop. (See lmgauss.m) Problem 5. For the given observed sequence x =(2.3, 1.78, 1.40, 0.10, 0.75, 0.65, 0.44, 0.58, 0.53, 0.05, 0.76, 0.63, 1.89, 0.48, 0.80, 0.40, 0.71, 0.93, 0.16, 2.4) construct the nonuniform quantizer using the Lloyd-Max procedure. (See lm.m and also p.37 in the book) Problem 6. Show that for the fixed-rate uniform scalar quantizer when the quantization step 0 the MSE 2 . Under this assumption estimate the rate-distortion function for the Gaussian 12 variable N (0, 2 ). Solution. Let f (x) be the probability density function (pdf) of the random variable X . Then when 0 we can assume that pdf is a constant inside each quantization cell, that is p j f ( y j ). Then we obtain tj ( x y j ) f ( y j )dx 2 j t j 1 j pj y j / 2 ( x y j ) dx 2 yj /2 y j / 2 1 p (x j 2 2 xy j y 2j )dx yj /2 j y j / 2 x2 y j / 2 x3 y j / 2 2 p 2 y y x j j j y j / 2 j 3 y j / 2 2 yj / 2 1 3 3 ( y j / 2) 2 ( y j / 2) 2 ( y j / 2) ( y j / 2) pj 2yj y 2j ( y j / 2 y j / 2) j 3 2 2 1 1 p j (( y j / 2)2 ( y j / 2)2 ( y 2j 2 / 4) y j 2 y j y 2j p j (3 y 2j ) y 2j j 3 4 j 3 1 2 12 p j j 2 12 . Choose 6 / 2 R since the probability that the Gaussian variable N (0, 2 ) belongs to the interval (3 ,3 ) is rather high. It is equal to 1 2Q(3) 0.9973. Then since 2 12 we obtain 36 2 3 2 2R 2 R 12 , 2 . By taking logarithm of the both parts we get 2 2 1 2 log 2 3 2 R log 2 3 , R log 2 H ( ) 0.7925. 2 2 2 Problem 7. For the given speech file in *.wav format : - split speech signal into frames of the given size (N); - for each frame find coefficients of the Yule-Walker equations of the given order using the autocorrelation method; - find the solution of the Yule-Walker equations using the Levinson-Durbin procedure; - plot the amplitude function of the prediction filter; - find the ideal excitation (prediction error) signal; - plot the amplitude function of the inverse filter; - scalar uniformly quantize filter coefficients and the error signal; - compute number of bits for fixed rate encoder; - compute compression ratio; - reconstruct speech signal using the obtained quantized data; - compute the relative squared error which occurs when we approximate the original speech signal by the reconstructed speech signal. Solution. Let x(nTs ) be the input speech signal. Then coefficients of the Yule-Walker equations can be computed as: Rˆ ( i j ) cij / N 1 / N N 1 i j x(nT ) x(nT n 0 s s i j Ts ). Since the coefficients are symmetric and have the Toeplitz property it is enough to compute only m 1 values, where m is the filter order. For example, we can compute c R( j 1) for 1j j 1,2,..., m 1. Then system of the Yule-Walker equations looks like m a R( i j ) R( j ), i 1 i j 1,..., m We initialize the Levinson-Durbin procedure by l 0, E0 c11, a ( 0 ) 0. For l 1 : m compute l 1 al( l ) ( R(l ) ai( l 1) R(l i )) / El 1 ; i 1 a(jl ) a(jl 1) all al(l j1) , 1 j l 1, El El 1 (1 (all ) 2 ). The obtained prediction filter can be described as follows m e(nTs ) x(nTs ) ai x(nTs iTs ) . i 1 It frequency function has the form m H (e jTs ) 1 ai e jiTs i 1 or using the normalized frequency / s m H (e j 2 ) 1 ai e j 2i . i 1 The amplitude function has the form m m i 1 i 1 A( ) (1 ai cos(2i)) 2 ( ai sin( 2i)) 2 . The amplitude function of the inverse filter has the form 1 AI ( ) m (1 ai cos( 2i )) ( ai sin( 2i )) i 1 . m 2 2 i 1 Let m 4 and the coefficients c1 j R( j 1) are equal to 3.79 107 , 2.85 107 , 6.62 106 , 1.46 107 , 2.48 107 . The normalized by R (0) coefficients are: 1 , 0.75, 0.17 , 0.38 , 0.65. The Levinson-Durbin procedure: Step 1: a11 c12 / c11 0.75 E E (1 (a11 )2 ) 3.79 107 (1 (0.75)2 ) 1.645 107. Step 2: a22 (c13 a11c12 ) / E (6.62 106 0.75 2.85 107 ) /(1.65 107 ) 0.902 a12 a11 (1 a22 ) 0.75 (1 0.902) 1.43 E E (1 (a22 )2 ) 1.645 107 (1 (0.902)2 ) 3.054 106 Step 3: a33 (c14 a12c13 a22c12 ) / E (1.46 107 1.43 6.62 106 0.902 2.85 107 ) /(3.054 106 ) 0.55 a13 a12 a33a22 1.43 0.55 (0.902) 1.928 a23 a22 a33a12 0.902 0.55 1.43 1.69 E E (1 (a33 ) 2 ) 3.054 106 (1 (0.55) 2 ) 2.13 106 Step 4: a44 (c15 a13c14 a23c13 a33c12 ) / E (2.48 107 1.928 1.46 107 1.69 6.62 106 0.55 2.85 107 ) / (2.13 106 ) 0.539 a14 a13 a44 a33 1.928 0.539 0.55 2.224 a24 a23 a44a23 1.69 (0.539) (1.69) 2.6 a34 a33 a44 a13 0.55 (0.539) 1.98 1.589 E E (1 (a44 )2 ) 2.13 106 (1 (0.539)2 ) 1.51 106 The normalized error is 0.0399. Let quantization step be equal to 0.02. Then quantized coefficients are: 111, 130, 79, 27 The number of bits for storing coefficients are : bits _ c m log 2 (max_ coeff min_ coeff 1) 4 log 2 (111 130 1) 32 . Let the quantization step for error signal be equal to step then the number of bits for storing the quantized error signal is bits _ err N log 2(max_ err min_ err 1) , where max_ err and min_ err are the maximum and the minimum values of error samples. The compression ratio is N 16 compr . bits _ c bits _ err (See also autocorr.m) Problem 8. For the given analysis filter bank (h0 (n), h1 (n)) find the frequency response of the lowpass and highpass filters. For the given input sequence check can the filter bank ( g0 (n), g1 (n)) be the inverse filter bank with respect to (h0 (n), h1 (n)) . Let h0 (n) (1,1,8,8,1,1) /(16 / 2 ) , h1 (n) (1,1) / 2 g 0 (n) (1,1) / 2 , g1 (n) (1,1,8,8,1,1) /(16 / 2 ) The input sequence x(n) (1,1,2,3,1,5,2) Solution The frequency response of the lowpass filter is 5 H 0 (e jTs ) h0 (n)e jnTs 16 / 2 1 e jTs 8e j 2Ts 8e j 3Ts e j 4Ts e j 5Ts . i 0 1 H1 (e jTs ) h1 (n)e jnTs 1 / 2 1 e jTs . i 0 The output of the lowpass filter is: y0 (n) (1,0,7,15,27,36,36,51,54,20,3,2) The output of the highpass filter is: y1 (n) (1,0,1,1,2,4,3,2) The decimated output of the lowpass filter: v0 (n) (1,7, 27,36,54, 3) The decimated output of the highpass filter: v1 (n) (1,1,2,3) The upsampled output of the lowpass filter is: ~ y0 (n) (1,0,7,0,27,0,36,0,54,0,3, ) The upsampled output of the highpass filter is: ~ y1 (n) (1,0,1,0,2,0,3) The lowpass filtered ~ y0 (n) is: w0 (n) (1,1,7,7,27,27,36,36,54,54,3,3) The highpass filtered ~ y1 (n) is: w1 (n) (1,1,7,9,11,5,12,20,26,22,3,3) Summing up w0 (n) and w1 (n) , and dividing by 16 we obtain xˆ (n) (0,0,0,1,1,2,3,1,5,2,0,0) x(n 3). Problem 9. Consider orthogonal analysis and synthesis wavelet filters : h0 (n) [2 6 3 1] / 50 , h1 (n) [1 3 - 6 2] / 50 , g0 (n) [1 3 6 2] / 50 , g1 (n) [2 - 6 3 1] / 50 . For the given input sequence of length N show that the use of cyclic extension allows to reconstruct the input sequence from the reference and detail sequences of length N / 2. Solution. Let input sequence be equal to: 1,2,3,4,5,6,7,8 . To avoid increasing of the transform length we perform cyclic extension of the input sequence that is we place L 1 first symbols to the end of the sequence, where L is the length of impulse response. In our case L 4 . Cyclically extended input sequence is: 1,2,3,4,5,6,7,8,1,2,3 Lowpass filtered sequence is: 20,10,21,31,41,51,61,71,65,27,13,23,7,3 Lowpass filtered sequence multiplied by window of length N delayed by L 1 symbols is: 31,41,51,61,71,65,27,13 Highpass filtered sequence is: 1,5,3,3,3,3,3,3,5,29,19,1,14,6 Highpass filtered sequence multiplied by window is: 3,3,3,3,3,3,5,29,19 Reference sequence is: 31,51,71,27 Detail sequence is: 3,3,3,29 Upsampled reference sequence is: 31,0,51,0,71,0,27,0 Upsampled detail sequence is: 3,0,3,0,3,0,29,0 Cyclically extended reference sequence is: 0,27,0,31,0,51,0,71,0,27,0 Cyclically extended detail sequence is: 0,29,0,3,0,3,0,3,0,29,0 Reconstructed low-frequency part is: 0,27,81,131,147,135,215,235,315,399,223,162,54,0 Reconstructed high-frequency part is: 0,58,174,81,47,15,15,15,15,49,177,87,29,0 Sum of low-frequency and high-frequency parts is: 0,85,255,50,100,150,200,250,300,350,400,75,25,0 After normalization by 1/ 50 and multiplying by window we obtain: 1,2,3,4,5,6,7,8 . (See also cyclext.m) Problem 10. Let matrix of the quantized DCT coefficients have the form: 115 3 1 1 0 0 0 0 12 2 1 1 0 0 0 0 0 1 1 0 0 0 0 0 1 0 0 0 0 0 0 3 1 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Construct codewords for run-length coding for AC coefficients. Construct codeword for DC coefficient if DC coefficient of the previous block is equal to 113. Solution The 1-D array of DCT coefficients obtained by scanning in zigzag order is: 115,3,12,0,2,1,1,1,1,3,1,1,1,1,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0 The corresponding codewords for run-length coding are: ((0,2),11) ((0,4),0011) ((1,2),10) ((0,1),1) (0,1),0) ((0,1),1) ((0,1),1) ((0,2),11) ((0,1),0) ((0,1),0) ((0,1),0) ((0,1),0) ((6,1),0) EOB Difference of DC coefficients is equal to 115113=2. It is coded as (2,10). (See also batdctcod.m) Problem 11. For the given frame of speech samples (bold font) 461 90 102 144 494 792 606 147 136 75 107 244 387 672 478 8 296 496 368 104 31 32 268 371 218 114 329 208 16 163 160 6 236 133 7 55 16 252 411 226 32 158 223 24 282 324 92 90 53 262 465 302 159 722 835 527 177 22 137 378 381 247 16 18 108 485 584 372 43 280 280 237 218 395 671 743 445 183 1 66 10 15 74 251 275 144 177 390 176 325 699 755 535 233 123 244 368 335 83 495 508 235 209 369 149 211 284 9 191 105 find pitch period (in the range 16-45). Solution To estimate the pitch period it is necessary to find the maximum over j of the match function 2 59 s (i ) s (i j ) , 16 j 45 . m( j ) i059 s(i j )2 i 0 We obtain m 106 ( 2.6070 1.0125 0.1362 0.1775 1.2626 1.5385 0.0011 1.2221 1.7722 0.3718 0.1492 0.1103 1.2155 1.2199 0.0629 0.3767 0.1611 2.8998 4.2192 1.4495 0.6896 0.2670 0.0811 0.3296 0.0123 The maximum value 4.2192 106 corresponds to j 38 (See also pitch_p.m) 2.6932 0.0674 0.3893 0.0092 1.1721). that is pitch period estimate is equal to 38.
© Copyright 2026 Paperzz