Matlab to calculate variance, mean value

Source: Internet
Author: User

Reference: http://www.cnblogs.com/linkr/articles/2297783.html

1. Mean value

Mathematical definition: An average is a measure of the trend in a set of data , which is the sum of all the data in a set of data divided by the number of this set of data. It is an indicator that reflects trends in the data set.

matlab function: Mean

>>x=[1,2,3]

>>mean (x) =2

If x is a matrix, its mean value is a vector group. Mean (x,1) is the mean of the column vector, and mean (x,2) is the mean of the row vector.

>>x=[1 2 3; 4 5 6]

>>mean (x,1) =[2.5 3.5 4.5]

>>mean (x,2) =2

5

Mean (mean (X)) if the mean of the entire matrix is required

>>mean (Mean (X)) =3.5

You can also use the MEAN2 function:

>>mean2 (X) =3.5

2. Variance

Mathematical definition: variance (Variance) is used to measure random variables and their mathematical expectations (i.e. mean values Degree of deviation.

Mean variance:

matlab function: var

>> y=[1 2 3 4]

>> var (Y) =1.6667

>> var (y,1) =1.25

Description: Var (y,0) Denominator is N-1,var (y,1) denominator is n

The above is the variance of the vector, the variance of the matrix is obtained.

>> var (X (:), 1) =2.9167

You can also use the standard deviation to find the variance, STD2 to find the standard deviation of the matrix

>>STD2 (x) *std2 (x) *5/6=2.9167% (std2 default is N-1)

Another use of standard deviation STD usage with Var

Matlab to calculate variance, mean value

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.