1.15  Review Exercises

If you are familiar with the material, you probably want to skip this section and check the exercises in Section 1.16.


1.1. What is the amplitude of a sinusoid x(t) with 30 dBm of power? And the amplitude of another sinusoid y(t) with 30 dB more power than x(t)? Is it correct to say that a signal has 30 dB of power? You can find the expression for the power of a sinusoid in Example 1.20. And you may want to read Appendix A.24 for a discussion about dB.
1.2. One has a discrete-time sinusoid with amplitude A = 10 volts and wants to generate discrete-time AWGN with power P such that the SNR equals 30 dB. What is the value of P in watts? What are the Matlab/Octave commands to generate both signals?
1.3. To review the alternatives to represent complex numbers, let a = 4ej0 and b = 3e2 be two complex numbers and calculate: c = ab, d = a + b, |c| and ∠c. Note that the following two forms of representing complex numbers in the polar notation are equivalent: me and m∠Θ.
1.4. Calculate by hand and plot the signal x[n] = Cean for n = 0,1,,3, where C = 3 + j4 and a = 2 + . Note that any complex-valued signal x[n] carries information about two real-valued signals and, describing x[n] with graphs requires one for its real component and another for its imaginary component. Alternatively, the two graphs can describe the magnitude and phase of x[n].
1.5. Describe in details the header and summarize the contents (list all the information you could extract from the header such as number of samples, sampling frequency, etc.) of the following companion files: tidigits_saa7.wav, timit_testdr8mpam0sx199.raw and timit_testdr8mpam0sx199.wav. These are files that store speech waveforms (TIDIGITS and TIMIT are famous corpora distributed by LDC – [ url1ldc]). Choose one of these files and analyze the corresponding signal via two plots: the waveform and the histogram of amplitudes, both with the abscissa and ordinate properly labeled.
1.6. Using your favorite programming language, list the code for reading raw (without header) files storing two kinds of data: a) floats (4 bytes) in little-endian format and b) shorts (2 bytes) in big-endian format. If you like the C language, you may find useful the companion code laps_dump.c.
1.7. Assume the random vector

X = [3;2;3;2;2;0;1;0;0;3;0;2;3;2;2;3;3;0;3;2;0].

a) Calculate its histogram. b) Estimate its probability mass function (PMF). c) Calculate the moments: mean 𝔼[X], variance 𝔼[(X μx)2] and 𝔼[X2]. You may find useful the discussion in Section 1.6.2 and Appendix A.19.3.
1.8. For calculating the variance using its definition 𝔼[(X μx)2] one has to go twice over the data samples. The first loop obtains the mean μx and the second loop calculates 𝔼[(X μx)2]. Show a code that uses only one pass over the data by adopting the expression 𝔼[(X μx)2] = 𝔼[X2] μx2 discussed in Appendix A.19.3.
1.9. a) Generate a realization (one waveform) of a Gaussian random process with 100 i.i.d. (independent and identically distributed) samples of a Gaussian with mean 4 and variance 3, that is, N(4,3). b) Generate a waveform with independent but not identically distributed samples: the samples with odd indexes are draw from N(4,3), while the samples with even indexes are draw from a uniform distribution U(5,7) with support [5,7]. You can check Section 1.6.2.
1.10. If the task is the generation of a vector of independent and identically distributed (i. i. d.) samples of random variables, one can simply generate each one independently and then organize them in a single vector. But if the task is to generate a vector with a given correlation among its elements, then a more sophisticated approach is required. Here, we practice the generation of two-dimensional Gaussian random vectors drawn from a PDF fX 1,X 2(x1,x2) with mean μ = (2,3)T and a given covariance matrix. Use the Matlab/Octave’s function mvnrnd or, if you do not have Matlab’s Statistics Toolbox installed, use the companion octave_mvnrnd instead. An example follows:

Listing 1.36: MatlabOctaveCodeSnippets/snip_signals_2Drandom.m. [ Python version]
1N = 100000; %number of 2-d vectors 
2mu=[2 3]; %mean 
3C=[1 0.5 ; 0.5 10]; %covariance matrix 
4r = octave_mvnrnd(mu,C,N); %octave_mvnrnd or mvnrnd 
5numbiny = 30; numbinx = 30; %number of bins for histogram 
6Cest=cov(r) %check estimated covariance matrix (should be close to C) 
7mu_est=mean(r) %estimated mean 
8R=C+mu'*mu %theoretical correlation matrix 
9Rest=Cest + mu_est'*mu_est %estimated correlation matrix 
10[n,xaxis,yaxis]=ak_hist2d(r(:,1),r(:,2),numbinx,numbiny); %histogram 
11mesh(xaxis,yaxis,n); pause %plot histogram 
12contour(xaxis,yaxis,n); xlabel('x1'); ylabel('x2'); %and its countour

The task is to generate realizations of two-dimensional Gaussian random variables, and compare their estimated probability mass functions (PMFs) for the following covariance matrices: a) C = σ2I = [ σ2 0 0 σ2 ] , σ2 = 0.5. b) C = [ σ12 0 0 σ22 ] , σ12 = 0.5 and σ22 = 4. c) C = [ σ12 σ12 σ21 σ22 ] , σ12 = σ21 = 0.5 and σ12 = σ22 = 1. Can you observe the interrelation between the correlations (σ12 and σ21, which are always equal because a covariance matrix is symmetric) and variances (σ12 and σ22) with the shape of the respective PMFs?