Friday, October 12, 2007

Basic probability in Matlab

Mean value

A =
1 2 0
2 3 0

mean(A) = 1.5000 2.5000 0 % Mean of each column

mean(A, 2) = % Mean of each row
1.0000
1.6667


Variance
  • V = var(X) returns
- for vectors X: its variance.
- for matrices: a row vector containing the variance of each column of X.

  • V = var(X,w,dim)
takes the variance along the dimension dim of X.
Pass in 0 for w to use the default normalization by N-1, or 1 to use N.
The variance is the square of the standard deviation (STD)

Example:
A =
1 2 0
2 3 0

var(A) =
0.5000 0.5000 0 % variance of columns

var(A, 0, 2) = % variance of rows
1.0000
2.3333

No comments: