[Matlab] covariance matrix calculation using the COV function results inconsistent with the self-programmed results

Source: Internet
Author: User

At present, it is unclear what is the reason, how much influence, only know the existence of this problem.

Run version:

1.matlabr2015b Windows64bit

2.https://octave-online.net/

3.http://www.compileonline.com/execute_matlab_online.php

Code:

The% self-compiled covariance matrix calculation method is consistent, but inconsistent with the COV function of Matlab rxx.mclose all;clear;clc;rng (' Default '); rng (0); A = Randn (10,4); [R,c]=size (A);% method 1rxx1=a ' *a/r;%method2for n=1:r rx2_0 (:,:, N) =a (n,:) ' *a (n,:); Endrxx2=sum (rx2_0,3)/r;% method 3rxx3=cov (A); fprintf (' err1=%f\n ', Sumsqr (rxx1-rxx2)); fprintf (' err2=%f\n ', Sumsqr (rxx1-rxx3)); fprintf (' err3=%f\n ') , SUMSQR (RXX2-RXX3));

  

Results

ERR1 close to 0,err2,err3 equal and equal to a certain number, compared with the corresponding matrix data, there are indeed differences.

todo~.~

[Matlab] covariance matrix calculation using the COV function results inconsistent with the self-programmed results

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.