"zz" matlab mean-value variance

Source: Internet
Author: User

Transferred from: http://blog.sina.com.cn/s/blog_4936c31d01011v8j.html

1 , mean value

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

Median, the median value of a set of data, the same usage as mean.

>>X=[1,2,9]

>>mean (X) =4

>>median (X) =2

2 , Variance

Mean variance:

Matlab function: Var

It is important to note that the Var function uses the formula, the denominator is not, but. This is because the Var function actually asks for not the variance, but rather the "estimate of the standard deviation of the finite secondary measurement data" in the error theory.

>>x=[1,2,3,4]

>>var (X) =1.6667

>> sum ((x (1,:)-mean (x)) ^2)/length (x) =1.2500

>> sum ((x (1,:)-mean (x)) ^2)/(Length (x)-1) =1.6667

var does not seek the variance function of the matrix, can use STD first to find the mean variance, and then squared to get the variance.

STD, mean variance, STD (x,0,1) to calculate the column vector Variance, STD (x,0,2) to calculate the row vector variance.

>>x=[1 2

3 4]

>>STD (x,0,1) =1.4142 1.4142

>>STD (x,0,2) =0.7071

0.7071

To require the mean variance of all elements of the entire matrix, use the STD2 function:

>>STD2 (X) =1.2910

4. Covariance matrix

A=[61.45,55.9,61.95,59,58.14,53.61,55.48,54.21,61.52,54.92];
B=[40.36,39.8,49.2,48,51.5,49.39,51.13,58.06,61,62.35];
C=[8.61,8.91,10.43,13.32,13.48,15.75,18.14,19.95,21.95,23.53];
D=[14.31,14.72,15.28,15.91,14.67,15,15.86,15.16,13.72,12.94];
E=[7.67,7.75,8.15,9.24,10.68,10.58,10.31,10,8.91,8.51];
>> q=[a ', B ', C ', D ', E '];
>> W=cov (q)
W =
10.3710-4.7446-6.6023-0.1873-1.8881
-4.7446 59.1503 38.7606-3.0743 3.0982
-6.6023 38.7606 28.6966-2.0199 2.4166
-0.1873-3.0743-2.0199 0.8474 0.3936
-1.8881 3.0982 2.4166 0.3936 1.3412

"zz" matlab mean-value variance

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.