Probability and Statistics Functions

random

Y = random(name,A,B,C,[m,n,…])


We can also use: rand for uniform, randn, trnd.

quantile, cdf, pdf, ipdf

quantile: Returns the empirical quantile of a vector.

x=randn(2000,1);
Median=quantile(x,0.5)
Q95=quantile(x,0.95)

cdf: Computes a chosen cumulative distribution function.

x=[2.1 3.2 1.1 -2 -0.5];
Fx=cdf('normal',x,0,1)
Fx =
0.9821 0.9993 0.8643 0.0228 0.3085

pdf: Computes Probability density function (pdf ) for a specified distribution.

x=[2.1 3.2 1.1 -2 -0.5];
fx=pdf('normal',x,0,1)
fx =
0.0440 0.0024 0.2179 0.0540 0.3521

icdf: Computes the inverse of the cumulative distribution function (quantile function).

x=[0.5 0.1 0.9 0.95];
iFx=icdf('normal',x,0,1)
iFx =
0 -1.2816

Exercises

  1. Compute the covariance matrix of the data.
  2. Compute the Cholesky decomposition of the covariance matrix.
  3. Compute the determinant of the covariance matrix.
  4. Extract the diagonal elements of the covariance matrix and compare
    them with the results of the command var.
  5. Compute the trace of the covariance matrix. Compute the sum of the
    eigenvalues of the covariance matrix.
  6. Generate a 100×1 vector of normally distributed pseudo-numbers with
    mean 0.5 and variance 0.25.
%d bloggers like this: