3

I've used the gmdistribution to fit data to a Gaussian mixture model. I wanted to plot a contour plot https://i.stack.imgur.com/d6Pdb.jpg where the contours are obviously missing. For a 1D problem I found fplot, but now I'm stumped.

enter image description here

Amro
  • 123,847
  • 25
  • 243
  • 454
Piotr Sokol
  • 245
  • 1
  • 13

1 Answers1

2

I ran into a similar problem when I wrote an EM algorithm for gaussian mixtures. Here is the snippet of code that fixed it in my case:

for l=1:k
        zz=gmdistribution(MU(l,:),SIG(:,:,l),PI(l));
        ezcontour(@(x,y)pdf(zz,[x y]),[minx1 maxx1],[miny1 maxy1],250);
end

The key is to increase N:

ezcontour(...,N) plots FUN over the default domain using an N-by-N
grid. The default value for N is 60.
AGS
  • 14,288
  • 5
  • 52
  • 67