Cursera: machine learning ex8.
This commit is contained in:
20
machine_learning/mlclass-ex8-008/mlclass-ex8/visualizeFit.m
Executable file
20
machine_learning/mlclass-ex8-008/mlclass-ex8/visualizeFit.m
Executable file
@@ -0,0 +1,20 @@
|
||||
function visualizeFit(X, mu, sigma2)
|
||||
%VISUALIZEFIT Visualize the dataset and its estimated distribution.
|
||||
% VISUALIZEFIT(X, p, mu, sigma2) This visualization shows you the
|
||||
% probability density function of the Gaussian distribution. Each example
|
||||
% has a location (x1, x2) that depends on its feature values.
|
||||
%
|
||||
|
||||
[X1,X2] = meshgrid(0:.5:35);
|
||||
Z = multivariateGaussian([X1(:) X2(:)],mu,sigma2);
|
||||
Z = reshape(Z,size(X1));
|
||||
|
||||
plot(X(:, 1), X(:, 2),'bx');
|
||||
hold on;
|
||||
% Do not plot if there are infinities
|
||||
if (sum(isinf(Z)) == 0)
|
||||
contour(X1, X2, Z, 10.^(-20:3:0)');
|
||||
end
|
||||
hold off;
|
||||
|
||||
end
|
||||
Reference in New Issue
Block a user