# Calculate covariance in Opencv

Dear forum followers I have a issue which I don't know how solve it.

I have a Mat like:

```
500.0 350.2
500.5 355.8
498.7 352.0
............
```

And I need calculate the covariance. The result would be something like:

```
0.8633 1.2167
1.2167 8.1733
```

Of course, the function which I need is **calcCovarMatrix**.... BUT if I execute these code:

```
cv::Mat a = (cv::Mat_<double>(3, 2) << 500.0, 350.2, 500.5, 355.8, 498.7, 352.0);
cv::Mat mu, new_covs;
cv::calcCovarMatrix(a, new_covs, mu, CV_COVAR_NORMAL | CV_COVAR_COLS);
The result is a incomprehensible 3x3 matrix...
new_covs=
[11220.02, 10838.03, 10987.83;
10838.03, 10469.045, 10613.745;
10987.83, 10613.745, 10760.445]
```

Another question:

If I have a set of clusters could I get the weight of these clusters like Expectation Maximization does it. How?: (http://docs.opencv.org/modules/ml/doc...)

I hope you can help my with my problem!!
**Thank you in advanced!**