visualizeFit.m 582 B

1234567891011121314151617181920
  1. function visualizeFit(X, mu, sigma2)
  2. %VISUALIZEFIT Visualize the dataset and its estimated distribution.
  3. % VISUALIZEFIT(X, p, mu, sigma2) This visualization shows you the
  4. % probability density function of the Gaussian distribution. Each example
  5. % has a location (x1, x2) that depends on its feature values.
  6. %
  7. [X1,X2] = meshgrid(0:.5:35);
  8. Z = multivariateGaussian([X1(:) X2(:)],mu,sigma2);
  9. Z = reshape(Z,size(X1));
  10. plot(X(:, 1), X(:, 2),'bx');
  11. hold on;
  12. % Do not plot if there are infinities
  13. if (sum(isinf(Z)) == 0)
  14. contour(X1, X2, Z, 10.^(-20:3:0)');
  15. end
  16. hold off;
  17. end