Professional Documents
Culture Documents
P1. Write the MATLAB code to produce a randomly generated number that follows the Bernoulli distribution for an arbitrary parameter, p. P2. Write the MATLAB code to produce a random variable that follows a binomial distribution for arbitrary parameters n, p. P3.Write the MATLAB code to simulate a random variable, Z, whose PMF is given by Pz(k) = 2k, k = 1, 2, 3, . . . .
P10. Use the MATLAB randn function to generate a large number of samples according to a Gaussian distribution. Let A be the event A = {the sample is greater than 1.5}. Of those samples that are members of the event A, what proportion (relative frequency) is greater than 2. By computing this proportion you will have estimated the conditional probability Pr(X > 2|X > 1. 5). Calculate the exact conditional probability analytically and compare it with the numerical results obtained through your MATLAB program.
P12. In this example, we generalize the results of the last example for an arbitrary number of quantization levels. When the number of quantization levels gets large, the number of equations to solve becomes too much to do by hand, so we use MATLAB to help us with this task. Again, we assume that the random variable X follows a Laplace distribution given by fX(x) = (1/2) exp (|x|). Because of the symmetry of this distribution, we again take advantage of the fact that the optimum quantizer will be symmetric. We design a quantizer with M levels for positive X (and hence M levels for negative X as well, for a total of 2M levels). The M quantization levels are at y1, y2, . . . yM, and the quantization bin edges are at x0 = 0, x1, x2, . . . , xN1, xN =.We compute the optimum quantizer in an iterative fashion. We start by arbitrarily setting the quantization bins in a uniform fashion. Lets choose to start with xi = 2i/M.