Can I calculate the covariance matrix of a large set of data?

In summary, you are trying to calculate the covariance matrix of a stochastic process using Matlab, but you are getting an error message because the matrix you are asking for would require a lot of memory.
  • #1
Frank Einstein
170
1
TL;DR Summary
I want to calculate the covariance matrix of a large set of data. However, I get an error telling me that said matrix would be too big and therefore It cannot be done.
Hello everyone. I want to calculate the covariance matrix of a stochastic process using Matlab as

Covariance matrix:
cov(listOfUVValues)

being the dimensions of listOfUVValues 211302*50. I get the following error:

Error:
Requested 211302x211302 (332.7GB) array exceeds maximum array size preference. Creation of arrays greater than this limit may take a long time and cause MATLAB to become
unresponsive. See array size limit or preference panel for more information.

Error in cov (line 156)
c = (xc' * xc) ./ denom;
;

Is there a way to go arround this limitation or is it impossible to do?

Any answer is appreciated.

Best regards.
 
Physics news on Phys.org
  • #2
There is no getting around the fact that you are asking for a matrix that will need a ton of memory. What do you need the covariance matrix for?

If there is some other end goal then there may be a better approach that bypasses the need to compute the covariance matrix at all. I'm not sure how much information you would even get from a 211302x211302 matrix that has a rank of at most 50.

If you just need a few elements of the covariance matrix, then you can estimate those directly.

jason
 
  • Like
Likes Frank Einstein
  • #3
Are you using the correct dimensions to represent each realisation? A 50x50 covariance matrix for 211k realisations sounds much more reasonable than vice versa.
 
  • Like
Likes FactChecker, Frank Einstein and jasonRF
  • #4
Yes, I have 50 realizations of a stochastic process, 50 valriables and 200k observations of each. I am trying to calculate the covariance between the windspeed in the X and Y directions using data from the ECMWF. I gess I will have to limit the region or the resolution.

Thanks anyway for your comments
 
  • #5
IMO, "50 realizations" is a misleading phrase. I interpret that phrase as 50 observations, each with a certain number of attributes (variables) recorded.
I think that you have your dimensions switched and, as @Orodruin suggested, your covariance matrix should be 50x50.
 
  • #6
I am following this thread. I have 50 wind predictions, each measured at 200k places, thus, each wind prediction is a realization of a random variable. I don't know if that helps
 

1. Can I calculate the covariance matrix of any type of data?

Yes, the covariance matrix can be calculated for any type of data, as long as it is a set of numerical values. However, the data should be continuous and not categorical.

2. How large is considered a "large" set of data for calculating a covariance matrix?

The size of the data set can vary depending on the specific problem, but generally, a data set with more than 30 observations is considered large enough to calculate a meaningful covariance matrix.

3. What is the purpose of calculating a covariance matrix?

A covariance matrix is used to understand the relationship between different variables in a data set. It helps identify if variables are positively or negatively correlated, and to what degree.

4. Can I use a calculator to calculate a covariance matrix?

Yes, there are calculators and software programs available that can perform the calculations for you. However, it is important to understand the formula and underlying concept of covariance to correctly interpret the results.

5. Is the calculation of a covariance matrix affected by outliers in the data?

Yes, outliers can greatly impact the results of a covariance matrix calculation. It is important to identify and handle outliers appropriately before calculating the covariance matrix.

Similar threads

  • MATLAB, Maple, Mathematica, LaTeX
Replies
1
Views
862
  • MATLAB, Maple, Mathematica, LaTeX
Replies
8
Views
1K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
1
Views
1K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
3
Views
2K
  • STEM Academic Advising
Replies
13
Views
2K
Back
Top