Estimate 2D covariance from 3D matrix where 3rd column contains probability density values
Show older comments
I have an nx3 matrix where the first 2 columns contain uniformly distributed random (x, y) points and the 3rd column contains pdf values evaluated at each point. The pdf values are computed from a normal distribution using zero mean and a specified covariance. Thus, the first 2 columns are independent while the 3rd column is dependent on the first 2. Here is code that generates a sample matrix:
n = 10000;
mu = [0, 0];
C = [12, 2; 2, 8]; % input covariance
X = [20 * (rand(n,1) - 0.5), 20 * (rand(n,1) - 0.5)]; % centers the grid at (0, 0)
X = [X, zeros(n,1)];
for k = 1:n
p = mvnpdf(X(k,1:2), mu, C); % returns pdf value
X(k,3) = p;
end
My question is how do I estimate the 2x2 covariance matrix that was used to generate my nx3 data? Given that I have the pdf values, it seems like this shouldn't be difficult to do, but I just can't figure out a simple solution.
Many thanks in advance!
Accepted Answer
More Answers (0)
Categories
Find more on Creating and Concatenating Matrices in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!