Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
hackassin
GitHub Repository: hackassin/Coursera-Machine-Learning
Path: blob/master/Week 9/Programming Assignment - 8/ex8/visualizeFit.m
616 views
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
8
[X1,X2] = meshgrid(0:.5:35);
9
Z = multivariateGaussian([X1(:) X2(:)],mu,sigma2);
10
Z = reshape(Z,size(X1));
11
12
plot(X(:, 1), X(:, 2),'bx');
13
hold on;
14
% Do not plot if there are infinities
15
if (sum(isinf(Z)) == 0)
16
contour(X1, X2, Z, 10.^(-20:3:0)');
17
end
18
hold off;
19
20
end
21