You are on page 1of 2

Probability Theory

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, . . . .

Random Variables, Distributions and Density Functions


P4.The MATLAB function rand generates random numbers that are uniformly distributed in the interval (0, 1) using an algorithm. To construct a histogram for the random numbers generated by rand, write a script that calls rand repeatedly. (Hint: Since we can do this only a finite number of times, lets quantize the range of the random numbers into increments of 0.1. We then calculate the number of times a random number falls in each quantized interval and divide by the total number of numbers generated for the example). P5. Construct a random variable X that is the sine of a uniform random phase. That is, we construct a random variable, , which is uniformly distributed over [0, 2), and then form a new random variable according to X = sin () and observe its PDF by plotting a histogram. P6. Write a MATLAB program to calculate the probability Pr(x1 X x2) if X is a Gaussian random variable for an arbitrary x1 and x2. (Hint: you will have to specify the mean and variance of the Gaussian random variable). P7. Write a MATLAB program to calculate the probability Pr(|X a| < b) if X is a Gaussian random variable for an arbitrary a and b > 0. Note that you will have to specify the mean and variance of the Gaussian random variable. P8. Use the MATLAB rand function to create a random variable X uniformly distributed over (0, 1). Then create a new random variable according to Y = ln(X). Repeat this procedure many times to create a large number of realizations of Y. Using these samples, estimate and plot the probability density function of Y. Find an analytical model that seems to fit your estimated PDF. P9. Use the MATLAB randn function to create a Gaussian distributed random variable X. Repeat this procedure and form a new random variable Y. Finally, form a random variable Z according to Z = (X2 + Y2)1/2. Repeat this procedure many times to create a large number of realizations of Z. Using these samples, estimate and plot the probability density function of Z.

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.

Statistical Operation on Single RVs


P11. Let X be a random variable uniformly distributed over (a/2, a/2). Accordingly, its PDF is of the form fX(x) =1/a{u(x + a/2)- u (x -a/2)}. A new random variable is to be formed according to the square law transformation Y = X2. By applying the theory developed in this section you should be able to demonstrate that the new random variable has a PDF given by fY(y) = (u(y) u(y a2/4))./( a y) Using MATLAB, create a large number of samples of the uniform random variable, pass these samples through the square law transformation, and then construct a histogram of the resulting probability densities.

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.

You might also like