Professional Documents
Culture Documents
0.1
Statistical Properties
Matlab has many functions that are used to statistically quantify a set of
numbers. The size of a matrix of numbers can be evaluated through the
statement \[N,col]=size(data)", which gives the number of rows (N) and
columns (col) of the matrix called \data". The Matlab command \mean(X)"
provides the mean of the vector X. If \data" has more than one column,
then each column can be vectorized using the statement \X(i)=data(:,i)",
which assigns the vector X(i) the elements in the i-th column of the matrix \data". Subsequently, one can nd the minimum value of X(i) by
the command \min(X(i))", the maximum by \max(X(i))", the standard
deviation by \std(X(i))", the variance by \[std(X(i))]^2", and the rootmean-square by \norm(X(i))/sqrt(N)". The command \norm(X(i),p)" equals
\sum(abs(X(i)).^p)^(1/p)". The default value of p is 2 if a value for p is
not entered into the argument of \norm", i.e., \norm(X(i))=norm(X(i),2)".
Other statistical properties, such as the mode, skewness and kurtosis can be
obtained by writing your own m-le using other Matlab commands.
0.2
The probability density and distribution functions for many common statistical distributions are available via Matlab's statistics toolbox. These include,
among others, the binomial (\bino"), Poisson (\poiss"), normal (\norm"),
Chi-square (\chi2"), lognormal (\logn"), Weibull (\weib"), uniform (\unif")
and exponential (\exp") distributions. Three Matlab functions used quite
often are \pdf", \cdf" and \inv", denoting the probability density, cumulative distribution and inverse functions, respectively. Matlab provides each of
these functions for specic distributions, where dierent input arguments are
required for each distribution. These functions carry a prex signifying the
abbreviated name of the distribution, as indicated above, and the sux of
either \pdf", \cdf" or \inv". For example, \normpdf" is the normal distribution probability density function. Matlab also provides generic \pdf" and
\cdf" functions for which one of the function's arguments is the abbreviated
name of the distribution.
1
0.3
To obtain a value of the normal error function, p(z1 ), using Matlab, we make
use of Matlab's \cdf" function. This is specied by Equation 1:
p (z1 ) = normcdf (z1 ; 0; 1)
0:5
(1)
Recall that normcdf is the integral of the normal probability density function
from 1 to x , or to z1 in this case. Because the normal error function
is dened between the limits of a normal mean equal to zero and z1 , we
must subtract a value of 0.5 from normcdf to obtain the correct normal
error function value. (Why 0.5?) For example, typing the Matlab command
2
normcdf (1:37; 0; 1)
0.4147.
0.5
~
When we need to determine the probability, P (z ), that a normally-distributed
value will lie between z , we can use the Matlab \cdf" function. This probability is determined by Equation 2:
~
P (z ) =
p(x)dx
normcdf ( z; 0; 1)
(2)
Using this formulation we can nd that P (2) = 0:9545. That is, 94.45% of
all normally-distributed values lie between z = 2. Further, recalling that
Matlab's P (z ) denotes the cdf value from 1 to z , a particular value of
a z can be obtained by typing the command \normcdf( 1 2 ; 0; 1)" and of
a +z by \normcdf( 1+2 ; 0; 1)". For example, typing the Matlab command
\normcdf( 1 029545 ; 0; 1)" gives the z-value of -2.00. A similar approach can
~
be taken to nd P for other distributions.
~
0.6
Student's t Distribution
The Matlab functions \tpdf", \tcdf" and \tinv" are used for Student's t
distribution. Matlab's command \tpdf(t,nu)" returns the value of the probability density function, p(t; ), evaluated at the value of t of Student's t
distribution having a nu degrees of freedom (recall that there are an innite
number of Student's t distribution, one for each degree of freedom value).
Specically, typing the Matlab command \tpdf(2,1000)" yields at value of
0.0541. Compare this to "normpdf(2,0,1)", which gives the value of 0.0540.
This shows that the probability density function value for Student's t distribution for a very number (here 1000) of degrees of freedom is eectively
the same as that of the normal distribution. However, for a low value of
the number of degrees of freedom, say equal to 2, the probability density
function value of Student's t distribution diers signicantly from its normal
distribution counterpart ( \tpdf(2,2)" yields a value of 0.0680).
3
0.7
Chi-Square Distribution
The Matlab functions \chi2pdf", \chi2cdf" and \chi2inv" are used for Chisquare distribution. Matlab's command \chi2pdf(chisq,nu)" returns the value
of the probability density function, p(2 ; ), evaluated at the value of 2 of
the Chi-square distribution having a nu degrees of freedom. Note that, like
for Student's t distribution, there are an innite number of Chi-square distributions. Typing the Matlab command \chi2pdf(10,10)" yields at value
of 0.0877. Typing \chi2cdf(10,10)" gives a value of 0.5595, signifying that
55.95% of all Chi-square-distributed values for 10 degrees of freedom lie between 0 and 10 (recall that there are no negative Chi-square values). Or,
in other words, there is a 44.15% chance of nding a value greater than 10
for a 10-degree-of-freedom Chi-square distribution. Similar to other specicdistribution \inv" functions, \chi2inv(P,nu)" returns the 2 value at which
between it and 0 lie P% of all the nu-degree-of-freedom Chi-square distribution values lie. For example, typing \chi2inv(95.96,4)" yields a value of
10.