Programming Assignments
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 MATLAB function rand generates an independent instance of a standard Gaussian random variable. That is, randn is a Gaussian random number generator:
.
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 MATLAB.
- rand
- Similarly, the MATLAB function rand generates independent
uniform
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 MATLAB.
- Histograms
- The MATLAB 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 MATLAB hist command,
the histogram is plotted automatically. To see an example of how
the histogram works, type the following in MATLAB:
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
, where each vector is
a column vector of length
drawn independently and identically
distributed according to some distribution, the sample mean of the
distribution is
The sample covariance is







