Aqua Phoenix
     >>  Lectures >>  Matlab 9  
 

Navigator
   
 
       
   

9.1 Mean, Variance, and Standard Deviation

Simple measures of statistics include the mean (average), standard deviation, and variance. Each of these can be easily computed in Matlab:

Given a vector of values, for example gasoline prices on the East Coast: v=data(:,1); The mean is: mean(v) The variance is: var(v) The Standard Deviation is: std(v)
Figure 9.1
Click image to enlarge, or click here to open
Given a matrix of random values, the mean, variance, and standard deviation are computed on a per column basis.

For example, for the matrix of all gasoline prices data:

mean, var, and std return vectors of values, one for each column:

mean(data)
std(data)
var(data)
Figure 9.2
Click image to enlarge, or click here to open

9.2 Min, Max

To select the minimum or maximum values from a vector, we use functions min and max . When used on vectors, min and max return scalars. When used on matrices, min and max return vectors with the minimum and maximum values determined from columns:

min(data)
max(data)
return the minimum and maximum values for prices in all regions.

Figure 9.3
Click image to enlarge, or click here to open
To find the envelope of minimum and maximum prices at any given point in time, we transpose the data matrix, thus casting each date into one column, and compute the min and max. The result can be plotted along with the mean.

lower=min(data');
upper=max(data');
avg=mean(data');
hold on;
plot(lower);
plot(upper);
plot(avg, 'r');
hold off;
Figure 9.4
Click image to enlarge, or click here to open