Advertisement
makispaiktis

Tutorial - Multivariate Gaussian

Aug 11th, 2021 (edited)
1,546
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
MatLab 0.50 KB | None | 0 0
  1. clc
  2. clear all
  3.  
  4. mean = [0 0];       % A 1x2 vector
  5. Sigma = [0.25 0.6; 0.6 2];
  6. % Sigma is 2x2 with Sigma(1,2) = Sigma(2,1) and Sigma(1,1) = σ^2 of 1st
  7. % dimension, Sigma(2,2) =  σ^2 of the 2nd dimension
  8.  
  9. x = -3: 0.1: 3;
  10. y = -3: 0.1: 3;
  11. [X, Y] = meshgrid(x, y);
  12. % Now, I will create the function
  13. F = mvnpdf([X(:) Y(:)], mean, Sigma);
  14. F = reshape(F, length(Y), length(X));
  15. surf(X, Y, F);
  16.  
  17. caxis([min(F(:)) - 0.5*range(F(:)), max(F(:))]);
  18. xlabel('x');
  19. ylabel('y');
  20. zlabel('Probability Density');
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement