www.pudn.com > gmm_utilities.zip > gmm_display_2D_contour.m


function x = gmm_display_2D_contour(g, prob, N, type) 
 
if nargin == 3, type=1; end 
if prob<=0 | prob>1, error('Probability outside (0, 1] bounds'), end 
 
% Sample gmm and evaluate 
x = gmm_samples(g, N); 
w = gmm_evaluate(g, x); 
 
% Find weights related to each requested prob 
ws = sort(w);  
ws = ws(ceil((1-prob)*N)); 
 
% Compute contour 
switch type 
case 1 % convex hull method 
    i = find(w >= ws); 
    x = x(:,i); 
    k = convhull(x(1,:), x(2,:)); 
    x = x(:,k); 
     
case 2 % search method 
    xs = x(:, w == ws); 
    % increment-length based on curvature 
     
otherwise 
    error('No other variations implemented')     
end