Statistics

Basic statistic

There are some widely used statistical measures in MATLAB.

Command Meaning Meaning
Mean mean(X) mean(X) returns the mean of the elements of X along the first array dimension whose size does not equal 1
Median median(X) If X is a vector, then median(X) returns the median value of X
Standard deviation std(X) std(X) returns the standard deviation of the elements of X along the first array dimension whose size does not equal 1
Variance var(X) var(X) returns the variance of the elements of X along the first array dimension whose size does not equal 1
Skewness skewness(X) skewness(X) returns the sample skewness of X
Kurtosis kurtosis(X) kurtosis(X) returns the sample kurtosis of X

Distribution function

The distribution functions below are widely useful in MATLAB. For each distribution in Matlab, there are five functions, which include probability density function (PDF), cumulative distribution function (CDF), inverse CDF, random numbers, and mean and variance.

Distribution String PDF CDF Inverse CDF Random Numbers
Normal distribution norm normpdf normcdf norminv normrnd
Exponential distribution exp exppdf expcdf expinv exprnd
Poisson distribution poiss poisspdf poisscdf poissinv poissrnd
Student's t-distribution t tpdf tcdf tinv trnd
F-distribution f fpdf fcdf finv frnd
Beta distribution beta betapdf betacdf betainv betarnd
Weibull distribution weib weibpdf weibcdf weibinv weibrnd
Chi-squared distribution chi2 chi2pdf chi2cdf chi2inv chi2rnd

Example:

p = normpdf(x, mu, sigma) % The default value of mu and sigma is 0 and 1.
P = normcdf(x, mu, sigma)
x = norminv(P, mu, sigma) % calculate the quantile value with given P (P is the probability).
M = normrnd(mu, sigma, m, n) % generate a m*n matrix using norm distribution function.

Note: in order to use a distribution with certain function, you just need to combine the name of the distribution with the name of certain function.

PDF CDF Inverse CDF Random Numbers Mean and Variance
pdf cdf inv rnd stat


Previous | Up | Next