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


function w = gmm_counting_algorithm(g, prob, N) 
%function w = gmm_counting_algorithm(g, prob, N) 
% 
% INPUTS: 
%   g - Gaussian mixture  
%   prob - probability mass to enclose [0, 1] 
%   N - number of samples to count 
% 
% OUTPUT: 
%   w - the (approximate) weight of g that marks the level-set enclosing 
%   mass, prob. 
% 
% Tim Bailey 2006. 
 
if prob<=0 | prob>=1 
    error('Probability must be in range (0,1)') 
end 
 
s = gmm_samples(g, N); 
w = gmm_evaluate(g, s); 
[ws, i] = sort(w); 
 
M = N - ceil(prob*N);  
M(M==0) = 1; 
w = ws(M);