Personal tools
  •  
You are here: Home Electrical and Computer Engineering Stochastic Processes Programming Assignments

Programming Assignments

Document Actions
  • Content View
  • Bookmarks
  • CourseFeed

Introduction   ::   Exercises

Introduction

This exercise will provide an opportunity to do some calculations and plots with actual data. The intent is to make some of the abstract concepts a little more concrete. This exercise is to be done using MATLAB.

Background

randn

Every call to the M ATLAB function rand generates an independent instance of a standard Gaussian random variable. That is, randn is a Gaussian random number generator: $ X \sim \Nc(0,1)$ . Random column vectors of length n are generated by randn(n,1) . Row vectors are generated with randn(1,n) . A matrix of random numbers is generated with randn(n,m) . For more information, type help randn in M ATLAB .

rand
Similarly, the M ATLAB function rand generates independent uniform $ \Uc(0,1)$ random numbers. Column and row vectors and matrices of random numbers are generated using rand(n,1) , rand(1,n) , rand(n,m) . For more information type help rand in M ATLAB .

Histograms
The M ATLAB hist command produces a histogram. This is a representation of the empirical density function. In a histogram, a sequence of bins is established. For each value in a set of data, the number of times that data points fall in a bin is counted. In the M ATLAB hist command, the histogram is plotted automatically. To see an example of how the histogram works, type the following in M ATLAB :
              x = randn(1,1000);   % create a vector of 1000 Gaussian random numbers
hist(x,20);  % plot the histogram with 20 bins
hist(x,100); % plot the histogram with 100 bins
             

Estimating mean and covariance
Given a sequence of vector observations $ \xbf_1, \xbf_2, \ldots, \xbf_N$ , where each vector is a column vector of length $ n$ drawn independently and identically distributed according to some distribution, the sample mean of the distribution is

$\displaystyle \hat{\mubf} = \frac{1}{N} \sum_{i=1}^N \xbf_i.
$

The sample covariance is

$\displaystyle \hat{\Sigma} = \frac{1}{N-1} \sum_{i=1}^N (\xbf_i -
\mubfhat)(\xbf_i - \mubfhat)^T.
$

Copyright 2008, Todd Moon. Cite/attribute Resource . admin. (2006, June 13). Programming Assignments. Retrieved January 07, 2011, from Free Online Course Materials — USU OpenCourseWare Web site: http://ocw.usu.edu/Electrical_and_Computer_Engineering/Stochastic_Processes/program1_1.htm. This work is licensed under a Creative Commons License Creative Commons License